Skip to content

Commit

Permalink
ESLint mechanical fixes.
Browse files Browse the repository at this point in the history
Extracted from microsoft#690

* Deleted a bunch of unreferenced files.
* Fixed files that were CRLF->LF.
* Fixed a few spelling mistakes.
  • Loading branch information
BillyONeal committed Sep 3, 2022
1 parent dfb8280 commit a45f1ac
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 234 deletions.
11 changes: 5 additions & 6 deletions ce/ce/amf/registries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import { isMap, isSeq, YAMLMap } from 'yaml';
import { Dictionary } from '../interfaces/collections';
import { ErrorKind } from '../interfaces/error-kind';
import { RegistryDeclaration } from '../interfaces/metadata/metadata-format';
import { Registry as IRegistry } from '../interfaces/metadata/registries/artifact-registry';
import { ArtifactRegistry, Registry as IRegistry } from '../interfaces/metadata/registries/artifact-registry';
import { ValidationMessage } from '../interfaces/validation-message';
import { isFilePath, Uri } from '../util/uri';
import { Entity } from '../yaml/Entity';
import { Strings } from '../yaml/strings';
import { Node, Yaml, YAMLDictionary, YAMLSequence } from '../yaml/yaml-types';

export class Registries extends Yaml<YAMLDictionary | YAMLSequence> implements Dictionary<RegistryDeclaration>, Iterable<[string, RegistryDeclaration]> {
*[Symbol.iterator](): Iterator<[string, RegistryDeclaration]> {
export class Registries extends Yaml<YAMLDictionary | YAMLSequence> implements Dictionary<ArtifactRegistry>, Iterable<[string, ArtifactRegistry]> {
*[Symbol.iterator](): Iterator<[string, ArtifactRegistry]> {
if (isMap(this.node)) {
for (const { key, value } of this.node.items) {
const v = this.createRegistry(value);
Expand Down Expand Up @@ -45,7 +44,7 @@ export class Registries extends Yaml<YAMLDictionary | YAMLSequence> implements D
return new YAMLSequence();
}

add(name: string, location?: Uri, kind?: string): RegistryDeclaration {
add(name: string, location?: Uri, kind?: string): ArtifactRegistry {
if (this.get(name)) {
throw new Error(`Registry ${name} already exists.`);
}
Expand Down Expand Up @@ -84,7 +83,7 @@ export class Registries extends Yaml<YAMLDictionary | YAMLSequence> implements D
}
return false;
}
get(key: string): RegistryDeclaration | undefined {
get(key: string): ArtifactRegistry | undefined {
const n = this.node;
if (isMap(n)) {
return this.createRegistry(<Node>n.get(key, true));
Expand Down
1 change: 1 addition & 0 deletions ce/ce/artifacts/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ export class Activation {
async function transformtoRecord<T, U = T> (
orig: AsyncGenerator<Promise<Tuple<string, T>>, any, unknown>,
// this type cast to U isn't *technically* correct but since it's locally scoped for this next block of code it shouldn't cause problems
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
func: (value: T) => U = (x => x as unknown as U)) {

return linq.values((await toArrayAsync(orig))).toObject(tuple => [tuple[0], func(tuple[1])]);
Expand Down
5 changes: 2 additions & 3 deletions ce/ce/artifacts/artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class Artifact extends ArtifactBase {

export function sanitizePath(path: string) {
return path.
replace(/[\\/]+/g, '/'). // forward slahses please
replace(/[\\/]+/g, '/'). // forward slashes please
replace(/[?<>:|"]/g, ''). // remove illegal characters.
// eslint-disable-next-line no-control-regex
replace(/[\x00-\x1f\x80-\x9f]/g, ''). // remove unicode control codes
Expand All @@ -276,7 +276,7 @@ export function sanitizePath(path: string) {

export function sanitizeUri(u: string) {
return u.
replace(/[\\/]+/g, '/'). // forward slahses please
replace(/[\\/]+/g, '/'). // forward slashes please
replace(/[?<>|"]/g, ''). // remove illegal characters.
// eslint-disable-next-line no-control-regex
replace(/[\x00-\x1f\x80-\x9f]/g, ''). // remove unicode control codes
Expand All @@ -288,7 +288,6 @@ export function sanitizeUri(u: string) {
}

export class ProjectManifest extends ArtifactBase {

}

export class InstalledArtifact extends Artifact {
Expand Down
2 changes: 1 addition & 1 deletion ce/ce/cli/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ export function count(num: number) {

export function position(text: string) {
return grey(`${text}`);
}
}
2 changes: 1 addition & 1 deletion ce/ce/cli/styling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function reformatText(text = '', session?: Session): string {
if (text) {
text = `${text}`.replace(/\\\./g, '\\\\.');

// rewrite file:// urls to be locl filesystem urls.
// rewrite file:// urls to be local filesystem urls.
return (!!text && !!session) ? text.replace(/(file:\/\/\S*)/g, (s, a) => yellow.dim(session.parseUri(a).fsPath)) : text;
}
return '';
Expand Down
50 changes: 25 additions & 25 deletions ce/ce/cli/switches/json.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { i } from '../../i18n';
import { session } from '../../main';
import { Uri } from '../../util/uri';
import { resolvePath } from '../command-line';
import { Switch } from '../switch';

export class Json extends Switch {
switch = 'json';
override multipleAllowed = false;
get help() {
return [
i`Dump environment variables and other properties to a json file with the path provided by the user.`
];
}

override get value(): Uri | undefined {
const v = resolvePath(super.value);
return v ? session.fileSystem.file(v) : undefined;
}

}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { i } from '../../i18n';
import { session } from '../../main';
import { Uri } from '../../util/uri';
import { resolvePath } from '../command-line';
import { Switch } from '../switch';

export class Json extends Switch {

switch = 'json';
override multipleAllowed = false;
get help() {
return [
i`Dump environment variables and other properties to a json file with the path provided by the user.`
];
}

override get value(): Uri | undefined {
const v = resolvePath(super.value);
return v ? session.fileSystem.file(v) : undefined;
}

}
27 changes: 0 additions & 27 deletions ce/ce/interfaces/metadata/alternative-fulfillment.ts

This file was deleted.

30 changes: 24 additions & 6 deletions ce/ce/interfaces/metadata/metadata-format.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { ProfileBase } from './profile-base';
import { GitRegistry } from './registries/git-registry';
import { LocalRegistry } from './registries/local-registry';
import { NugetRegistry } from './registries/nuget-registry';
import { Dictionary } from '../collections';
import { Contact } from './contact';
import { Demands } from './demands';
import { ArtifactRegistry } from './registries/artifact-registry';

type Primitive = string | number | boolean;

/**
* a profile defines the requirements and/or artifact that should be installed
*
* Any other keys are considered HostQueries and a matching set of Demands
* A HostQuery is a query string that can be used to qualify
* 'requires'/'see-also'/'exports'/'install'/'use' objects
*
* @see the section below in this document entitled 'Host/Environment Queries"
*/
export type Profile = ProfileBase;

export type RegistryDeclaration = NugetRegistry | LocalRegistry | GitRegistry;
export interface Profile extends Demands {
/** any contact information related to this profile/package */
contacts: Dictionary<Contact>; // optional

/** artifact registries list the references necessary to install artifacts in this file */
registries?: Dictionary<ArtifactRegistry>;

/** global settings */
globalSettings: Dictionary<Primitive | Record<string, unknown>>;

/** is this document valid */
readonly isFormatValid: boolean;

/** parsing errors in this document */
readonly formatErrors: Array<string>;
}


/** values that can be either a single string, or an array of strings */
export type StringOrStrings = string | Array<string>;
27 changes: 0 additions & 27 deletions ce/ce/interfaces/metadata/paths.ts

This file was deleted.

37 changes: 0 additions & 37 deletions ce/ce/interfaces/metadata/profile-base.ts

This file was deleted.

8 changes: 0 additions & 8 deletions ce/ce/interfaces/metadata/registries/git-registry.ts

This file was deleted.

8 changes: 0 additions & 8 deletions ce/ce/interfaces/metadata/registries/local-registry.ts

This file was deleted.

8 changes: 0 additions & 8 deletions ce/ce/interfaces/metadata/registries/nuget-registry.ts

This file was deleted.

1 change: 0 additions & 1 deletion ce/ce/registries/ArtifactRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,4 @@ export abstract class ArtifactRegistry implements Registry {
async save(): Promise<void> {
await this.indexYaml.writeFile(Buffer.from(`${THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING}\n${serialize(this.index.serialize()).replace(/\s*(\d*,)\n/g, '$1')}`));
}

}
1 change: 0 additions & 1 deletion ce/ce/registries/LocalRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Session } from '../session';
import { Uri } from '../util/uri';
import { ArtifactRegistry } from './ArtifactRegistry';


export class LocalRegistry extends ArtifactRegistry implements Registry {
protected indexYaml: Uri;
readonly installationFolder;
Expand Down
8 changes: 3 additions & 5 deletions ce/ce/registries/RemoteRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
// Licensed under the MIT License.

import { strict } from 'assert';
import { createHash } from 'crypto';
import { parse } from 'yaml';
import { ZipUnpacker } from '../archivers/ZipUnpacker';
import { Registry } from '../artifacts/registry';
import { registryIndexFile } from '../constants';
import { acquireArtifactFile } from '../fs/acquire';
import { i } from '../i18n';
import { Session } from '../session';
import { isGithubRepo } from '../util/checks';
import { Uri } from '../util/uri';
import { ArtifactIndex } from './artifact-index';
import { ArtifactRegistry } from './ArtifactRegistry';
import { Index } from './indexer';
import { createHash } from 'crypto';
import { isGithubRepo } from '../util/checks';

export class RemoteRegistry extends ArtifactRegistry implements Registry {

protected indexYaml: Uri;
readonly installationFolder;
readonly cacheFolder: Uri;
Expand Down Expand Up @@ -62,7 +61,6 @@ export class RemoteRegistry extends ArtifactRegistry implements Registry {
}

override async load(force?: boolean): Promise<void> {

if (force || !this.loaded) {
if (!await this.indexYaml.exists()) {
await this.update();
Expand Down Expand Up @@ -96,4 +94,4 @@ export class RemoteRegistry extends ArtifactRegistry implements Registry {
await file.delete();
}
}
}
}
3 changes: 0 additions & 3 deletions ce/ce/registries/https-registry.ts

This file was deleted.

11 changes: 1 addition & 10 deletions ce/ce/registries/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { Range, SemVer } from 'semver';
import BTree from 'sorted-btree';
import { i } from '../i18n';
import { isIterable } from '../util/checks';
import { intersect } from '../util/intersect';
import { entries, keys, ManyMap, Record } from '../util/linq';
import { entries, ManyMap } from '../util/linq';

/* eslint-disable @typescript-eslint/ban-types */

Expand Down Expand Up @@ -107,14 +106,6 @@ abstract class Key<TGraph extends Object, TKey extends HasToString, TIndexSchema
readonly identity: string;
readonly alternativeIdentities: Array<string>;

/** attaches a nested key in the index. */
with<TNestedKey extends Record<string, Key<TGraph, any, TIndexSchema>>>(nestedKey: TNestedKey): Key<TGraph, TKey, TIndexSchema> & TNestedKey {
for (const child of keys(nestedKey)) {
this.nestedKeys.push(nestedKey[child]);
}
return intersect(this, nestedKey);
}

/** persists the key to an object graph */
serialize() {
const result = <any>{
Expand Down
Loading

0 comments on commit a45f1ac

Please sign in to comment.