depflow 3.0.0-dev.11 → 3.0.0-dev.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/bin.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * @author NetFeez <netfeez.dev@gmail.com>.
4
+ * @description Command-line entry point: hands the tokens of the invocation to the console interface, which
5
+ * reads the command, its arguments and its flags, and answers the verdict of the line.
6
+ * @license Apache-2.0
7
+ */
2
8
  export {};
package/dist/cli/bin.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * @author NetFeez <netfeez.dev@gmail.com>.
4
- * @description Command-line entry point: parses arguments and dispatches the invoked command to the CLI.
4
+ * @description Command-line entry point: hands the tokens of the invocation to the console interface, which
5
+ * reads the command, its arguments and its flags, and answers the verdict of the line.
5
6
  * @license Apache-2.0
6
7
  */
7
- import Logger from "@netfeez/vterm";
8
- import DepFlowCLI, { options } from "./DepFLowCLI.js";
8
+ import DepflowCLI from "./DepflowCLI.js";
9
+ /** The tokens Node puts in front of the invocation: the interpreter and the entry point. **/
9
10
  const skip = 2;
10
- const [commandName, ...argsList] = process.argv.slice(skip);
11
11
  /**
12
12
  * Reports a failure to the user and marks the process as failed.
13
13
  *
@@ -26,7 +26,7 @@ const [commandName, ...argsList] = process.argv.slice(skip);
26
26
  * of the commands is still in it. The status a user observes is the same one in both, because the run
27
27
  * is already over by the time this is called; what changes is whether the transcript survives it.
28
28
  *
29
- * @param out - The logger or engine the failure is reported to.
29
+ * @param out - The engine the failure is reported to.
30
30
  * @param error - The failure, either an error or a message.
31
31
  * @returns void
32
32
  */
@@ -34,35 +34,11 @@ function fail(out, error) {
34
34
  out.error(`&C1${error?.message || error}`);
35
35
  process.exitCode = 1;
36
36
  }
37
- let parsed;
37
+ const cli = new DepflowCLI();
38
38
  try {
39
- parsed = options.parse(argsList);
39
+ await cli.invoke(process.argv.slice(skip));
40
40
  }
41
41
  catch (error) {
42
- fail(new Logger(), error);
43
- }
44
- // A failed parse leaves nothing to dispatch: the invocation was never understood, so there is no command
45
- // to run and no CLI to run it with. The process still ends here, with the status `fail` marked.
46
- if (parsed !== undefined) {
47
- const { args, flags } = parsed;
48
- const cli = new DepFlowCLI(flags.flow);
49
- try {
50
- if (commandName !== null) {
51
- const command = cli.getCommand(commandName);
52
- if (command) {
53
- const exec = command.exec;
54
- await exec.call(cli, commandName, args, flags);
55
- }
56
- else {
57
- cli.out.error(`Unknown command: ${commandName}`);
58
- cli.getCommand('help')?.exec.call(cli, 'help', []);
59
- }
60
- }
61
- else
62
- cli.start();
63
- }
64
- catch (error) {
65
- fail(cli.out, error);
66
- }
42
+ fail(cli.out, error);
67
43
  }
68
44
  //# sourceMappingURL=bin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":";AACA;;;;GAIG;AACH,OAAO,MAAuB,MAAM,gBAAgB,CAAC;AAErD,OAAO,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGtD,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAS,IAAI,CAAC,GAAoB,EAAE,KAAU;IAC1C,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,IAAI,MAAoD,CAAC;AACzD,IAAI,CAAC;IAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAC,CAAC;AACzC,OAAO,KAAU,EAAE,CAAC;IAAC,I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C,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,GAAG,GAAG,IAAI,UAAU,EAAE,CAAC;AAE7B,IAAI,CAAC;IAAC,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAAC,CAAC;AACnD,OAAO,KAAU,EAAE,CAAC;IAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAAC,CAAC"}
@@ -242,7 +242,7 @@ export declare class Config extends Settings<typeof schema.Config, Document> {
242
242
  readonly type: "string";
243
243
  readonly required: true;
244
244
  readonly pattern: RegExp;
245
- readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not a path: a single alphanumeric segment.";
245
+ readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not an arbitrary path: a `<user>/<repo>` pair or a single alphanumeric segment.";
246
246
  };
247
247
  readonly repo: {
248
248
  readonly type: "string";
@@ -5,15 +5,43 @@
5
5
  */
6
6
  export declare namespace DepUtils {
7
7
  /**
8
- * Anything `git clone` accepts as a repository: a remote over one of the transports it speaks, or
9
- * a local path of a repository. The name of a dependency is never derived from it, only the repo
10
- * itself is.
8
+ * A repository in the canonical form `git clone` accepts: a remote over one of the transports it
9
+ * speaks, or a local path of a repository, always ending in `.git`. The name of a dependency is
10
+ * never derived from it, only the repo itself is.
11
11
  *
12
12
  * @remarks Every transport is spelled out so the accepted shapes are readable, but the `.git`
13
13
  * suffix is what all of them share and what {@link DepUtils.repo} enforces, so the last member is
14
14
  * the one that decides.
15
15
  */
16
16
  type Repo = `https://${string}.git` | `http://${string}.git` | `ssh://${string}.git` | `git://${string}.git` | `file://${string}.git` | `git@${string}.git` | `${string}.git`;
17
+ /**
18
+ * What a repository reference resolves to: the URL `git clone` is given and the name GitHub
19
+ * derives from it.
20
+ */
21
+ interface Reference {
22
+ /** The repository, canonical: a value {@link DepUtils.Repo} accepts whatever form it came in. */
23
+ repo: Repo;
24
+ /** The `<user>/<name>` GitHub derives, or `null` when the reference is not a GitHub one. **/
25
+ name: string | null;
26
+ }
27
+ /**
28
+ * Parses a repository reference into the repository git clones from and the name GitHub derives.
29
+ *
30
+ * A GitHub repository may be written as the bare `user/repo` shorthand, as an HTTP(S) URL or as an
31
+ * SCP like ssh address, with or without the `.git` suffix; every one of them is canonicalized to
32
+ * the same repository. Any other repository is accepted as it stands when it is a value
33
+ * {@link DepUtils.Repo} accepts, and carries no derivable name.
34
+ * @param reference - The repository reference as a user writes it.
35
+ * @returns The canonical repository and the derived name, `null` when there is none.
36
+ * @throws { Error } When the reference is not a clonable repository.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * DepUtils.parse('netfeez/omega');
41
+ * // { repo: 'https://github.com/netfeez/omega.git', name: 'netfeez/omega' }
42
+ * ```
43
+ */
44
+ function parse(reference: string): Reference;
17
45
  /**
18
46
  * Validates that the provided value is a repository `git clone` accepts, and says what it is not when
19
47
  * it does not: a URL with its scheme, an SCP like address or a local path of a repository.
@@ -31,18 +59,18 @@ export declare namespace DepUtils {
31
59
  */
32
60
  function repo(repo: unknown): asserts repo is Repo;
33
61
  /**
34
- * Extracts the name a dependency is known by from its repository URL.
62
+ * Extracts the name a dependency is known by from its repository reference.
35
63
  *
36
64
  * Only a GitHub repository has a name that can be derived without asking, and the name it derives
37
65
  * is the one the alias of the dependency takes everywhere else, so it is derived here and nowhere
38
66
  * else.
39
- * @param repo - The repository URL.
40
- * @returns The repository name, as `<user>.<name>`.
67
+ * @param repo - The repository reference, in any of the forms {@link DepUtils.parse} accepts.
68
+ * @returns The repository name, as `<user>/<name>`.
41
69
  * @throws { Error } When the repository is not a GitHub one, saying the name has to be given.
42
70
  *
43
71
  * @example
44
72
  * ```ts
45
- * DepUtils.getRepoName('https://github.com/NetFeez/omega.git'); // 'NetFeez.omega'
73
+ * DepUtils.getRepoName('https://github.com/NetFeez/omega.git'); // 'NetFeez/omega'
46
74
  * ```
47
75
  */
48
76
  function getRepoName(repo: string): string;
@@ -11,14 +11,68 @@ export var DepUtils;
11
11
  */
12
12
  const CLONEABLE_REGEX = /^(?:(?:https?|ssh|git|file):\/\/|git@)\S+$|\S*\.git$/;
13
13
  /**
14
- * Matches a github repository URL and captures its user and name, tolerating a missing `.git` suffix.
14
+ * Matches a GitHub repository over HTTP, with or without the `.git` suffix, and captures its user
15
+ * and name.
15
16
  */
16
- const GITHUB_REPO_REGEX = /^(?:https:\/\/github\.com\/([^/]+)\/([^/.]+)(?:\.git)?|git@github\.com:([^/]+)\/([^/.]+)(?:\.git)?)$/;
17
+ const GITHUB_HTTP_REGEX = /^(https?):\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/;
18
+ /**
19
+ * Matches a GitHub repository over SSH in the SCP like form, with or without the `.git` suffix and
20
+ * tolerating the stray slash some clients write after the colon (`git@github.com:/user/repo`).
21
+ */
22
+ const GITHUB_SSH_REGEX = /^git@github\.com:?\/?([^/]+)\/([^/]+?)(?:\.git)?$/;
23
+ /**
24
+ * Matches the bare `user/repo` shorthand GitHub itself accepts, without a scheme and with or
25
+ * without the `.git` suffix.
26
+ */
27
+ const GITHUB_SHORT_REGEX = /^([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*?)(?:\.git)?$/;
17
28
  /**
18
29
  * The suffix that tells a repository from anything else, checked on the value as a whole instead of
19
30
  * anchoring it, so a local path of a repository keeps validating wherever it lives.
20
31
  */
21
32
  const GIT_SUFFIX_REGEX = /\.git$/;
33
+ /**
34
+ * The failure every rejected reference is reported with, so a caller sees what was expected of it.
35
+ * @param reference - The value that was refused.
36
+ * @returns The error describing what a repository reference may be.
37
+ **/
38
+ function notClonable(reference) {
39
+ return new Error(`Not a clonable git repository: "${reference}". Pass a user/repo pair, a repository ending in .git, a URL git can clone, an ssh address or a local path of a repository.`);
40
+ }
41
+ /**
42
+ * Parses a repository reference into the repository git clones from and the name GitHub derives.
43
+ *
44
+ * A GitHub repository may be written as the bare `user/repo` shorthand, as an HTTP(S) URL or as an
45
+ * SCP like ssh address, with or without the `.git` suffix; every one of them is canonicalized to
46
+ * the same repository. Any other repository is accepted as it stands when it is a value
47
+ * {@link DepUtils.Repo} accepts, and carries no derivable name.
48
+ * @param reference - The repository reference as a user writes it.
49
+ * @returns The canonical repository and the derived name, `null` when there is none.
50
+ * @throws { Error } When the reference is not a clonable repository.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * DepUtils.parse('netfeez/omega');
55
+ * // { repo: 'https://github.com/netfeez/omega.git', name: 'netfeez/omega' }
56
+ * ```
57
+ */
58
+ function parse(reference) {
59
+ if (typeof reference !== 'string' || !reference.trim())
60
+ throw notClonable(reference);
61
+ const value = reference.trim();
62
+ const http = value.match(GITHUB_HTTP_REGEX);
63
+ if (http)
64
+ return { repo: `${http[1]}://github.com/${http[2]}/${http[3]}.git`, name: `${http[2]}/${http[3]}` };
65
+ const ssh = value.match(GITHUB_SSH_REGEX);
66
+ if (ssh)
67
+ return { repo: `git@github.com:${ssh[1]}/${ssh[2]}.git`, name: `${ssh[1]}/${ssh[2]}` };
68
+ const short = value.match(GITHUB_SHORT_REGEX);
69
+ if (short)
70
+ return { repo: `https://github.com/${short[1]}/${short[2]}.git`, name: `${short[1]}/${short[2]}` };
71
+ if (!CLONEABLE_REGEX.test(value) || !GIT_SUFFIX_REGEX.test(value))
72
+ throw notClonable(value);
73
+ return { repo: value, name: null };
74
+ }
75
+ DepUtils.parse = parse;
22
76
  /**
23
77
  * Validates that the provided value is a repository `git clone` accepts, and says what it is not when
24
78
  * it does not: a URL with its scheme, an SCP like address or a local path of a repository.
@@ -42,28 +96,25 @@ export var DepUtils;
42
96
  }
43
97
  DepUtils.repo = repo;
44
98
  /**
45
- * Extracts the name a dependency is known by from its repository URL.
99
+ * Extracts the name a dependency is known by from its repository reference.
46
100
  *
47
101
  * Only a GitHub repository has a name that can be derived without asking, and the name it derives
48
102
  * is the one the alias of the dependency takes everywhere else, so it is derived here and nowhere
49
103
  * else.
50
- * @param repo - The repository URL.
51
- * @returns The repository name, as `<user>.<name>`.
104
+ * @param repo - The repository reference, in any of the forms {@link DepUtils.parse} accepts.
105
+ * @returns The repository name, as `<user>/<name>`.
52
106
  * @throws { Error } When the repository is not a GitHub one, saying the name has to be given.
53
107
  *
54
108
  * @example
55
109
  * ```ts
56
- * DepUtils.getRepoName('https://github.com/NetFeez/omega.git'); // 'NetFeez.omega'
110
+ * DepUtils.getRepoName('https://github.com/NetFeez/omega.git'); // 'NetFeez/omega'
57
111
  * ```
58
112
  */
59
113
  function getRepoName(repo) {
60
- const match = repo.match(GITHUB_REPO_REGEX);
61
- if (match) {
62
- const user = match[1] || match[3];
63
- const repoName = match[2] || match[4];
64
- return `${user}.${repoName}`;
65
- }
66
- throw new Error(`Cannot derive a name from "${repo}": only GitHub repositories are named automatically, pass the name yourself.`);
114
+ const { name } = parse(repo);
115
+ if (!name)
116
+ throw new Error(`Cannot derive a name from "${repo}": only GitHub repositories are named automatically, pass the name yourself.`);
117
+ return name;
67
118
  }
68
119
  DepUtils.getRepoName = getRepoName;
69
120
  })(DepUtils || (DepUtils = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"DepUtils.js","sourceRoot":"","sources":["../../src/dependency/DepUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,KAAW,QAAQ,CAiFxB;AAjFD,WAAiB,QAAQ;IAmBrB;;;OAGG;IACH,MAAM,eAAe,GAAG,sDAAsD,CAAC;IAE/E;;OAEG;IACH,MAAM,iBAAiB,GAAG,sGAAsG,CAAC;IAEjI;;;OAGG;IACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IAElC;;;;;;;;;;;;;;OAcG;IACH,SAAgB,IAAI,CAAC,IAAa;QAC9B,IAAI,OAAO,IAAI,KAAK,QAA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only description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not a path: a single alphanumeric segment.";
242
+ readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not an arbitrary path: a `<user>/<repo>` pair or a single alphanumeric segment.";
243
243
  };
244
244
  readonly repo: {
245
245
  readonly type: "string";
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import Schema from '@netfeez/schema';
7
7
  export declare namespace DependencyName {
8
- /** A single path segment: the identity of a git source, also the name of its checkout folder. */
8
+ /** A `user/repo` identity or a single segment: the identity of a git source, also the name of its checkout folder. */
9
9
  const GIT: RegExp;
10
10
  /** A package name, optionally scoped: the identity of an npm source. */
11
11
  const NPM: RegExp;
@@ -18,7 +18,7 @@ export declare const GitDependency: Schema<{
18
18
  readonly type: "string";
19
19
  readonly required: true;
20
20
  readonly pattern: RegExp;
21
- readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not a path: a single alphanumeric segment.";
21
+ readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not an arbitrary path: a `<user>/<repo>` pair or a single alphanumeric segment.";
22
22
  };
23
23
  readonly repo: {
24
24
  readonly type: "string";
@@ -450,7 +450,7 @@ export declare const Dependency: {
450
450
  readonly type: "string";
451
451
  readonly required: true;
452
452
  readonly pattern: RegExp;
453
- readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not a path: a single alphanumeric segment.";
453
+ readonly description: "Unique name used to reference the dependency in flows and path aliases. It is an identity, not an arbitrary path: a `<user>/<repo>` pair or a single alphanumeric segment.";
454
454
  };
455
455
  readonly repo: {
456
456
  readonly type: "string";
@@ -13,8 +13,8 @@ export var DependencyName;
13
13
  * The identities the flow folder reserves for itself, declared once so no source can claim them.
14
14
  */
15
15
  const RESERVED = 'schema\\.json|node_modules';
16
- /** A single path segment: the identity of a git source, also the name of its checkout folder. */
17
- DependencyName.GIT = new RegExp(`^(?!(${RESERVED})$)[A-Za-z0-9][A-Za-z0-9._-]*$`);
16
+ /** A `user/repo` identity or a single segment: the identity of a git source, also the name of its checkout folder. */
17
+ DependencyName.GIT = new RegExp(`^(?!(?:${RESERVED})(?:/|$))[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._-]*)?$`);
18
18
  /** A package name, optionally scoped: the identity of an npm source. */
19
19
  DependencyName.NPM = new RegExp(`^(?!(${RESERVED})$)@?[A-Za-z0-9][A-Za-z0-9._~-]*(/[A-Za-z0-9][A-Za-z0-9._~-]*)?$`);
20
20
  })(DependencyName || (DependencyName = {}));
@@ -25,7 +25,7 @@ export const GitDependency = new Schema({
25
25
  type: 'string',
26
26
  required: true,
27
27
  pattern: DependencyName.GIT,
28
- description: 'Unique name used to reference the dependency in flows and path aliases. It is an identity, not a path: a single alphanumeric segment.'
28
+ description: 'Unique name used to reference the dependency in flows and path aliases. It is an identity, not an arbitrary path: a `<user>/<repo>` pair or a single alphanumeric segment.'
29
29
  },
30
30
  repo: {
31
31
  type: 'string',
@@ -1 +1 @@
1
- {"version":3,"file":"Dependency.js","sourceRoot":"","sources":["../../../src/schema/Config/Dependency.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,KAAW,cAAc,CAa9B;AAbD,WAAiB,cAAc;IAE3B;;OAEG;IACH,MAAM,QAAQ,GAAG,4BAA4B,CAAC;IAE9C,iGAAiG;IACpF,kBAAG,GAAW,IAAI,MAAM,CAAC,QAAQ,QAAQ,gCAAgC,CAAC,CAAC;IAExF,wEAAwE;IAC3D,kBAAG,GAAW,IAAI,MAAM,CAAC,QAAQ,QAAQ,kEAAkE,CAAC,CAAC;AAE9H,CAAC,EAbgB,cAAc,KAAd,cAAc,QAa9B;AAGD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,C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AAO,EAAE;YACL,GAAG,OAAO,CAAC,UAAU;YACrB,IAAI,OAAO,KAAK,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1C,WAAW,EAAE,sDAAsD;SACtE;QACD,QAAQ,EAAE;YACN,GAAG,QAAQ,CAAC,UAAU;YACtB,IAAI,OAAO,KAAK,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC3C,WAAW,EAAE,yDAAyD;SACzE;KACJ;CACJ,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;IACpC,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACF,IAAI,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,cAAc,CAAC,GAAG;YAC3B,WAAW,EAAE,iDAAiD;SACjE;QACD,OAAO,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,iDAAiD;SACjE;QACD,OAAO,EAAE;YACL,GAAG,OAAO,CAAC,UAAU;YACrB,IAAI,OAAO,KAAK,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1C,WAAW,EAAE,sDAAsD;SACtE;QACD,QAAQ,EAAE;YACN,GAAG,QAAQ,CAAC,UAAU;YACtB,IAAI,OAAO,KAAK,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YAC3C,WAAW,EAAE,yDAAyD;SACzE;KACJ;CACJ,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAK3D,eAAe,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "depflow",
3
3
  "description": "is a simple dependency manager based on github repositories",
4
- "version": "3.0.0-dev.11",
4
+ "version": "3.0.0-dev.13",
5
5
  "main": "dist/cli/bin.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "dep": "dist/cli/bin.js"
8
+ "dep": "dist/cli/bin.js",
9
+ "depflow": "dist/cli/bin.js"
9
10
  },
10
11
  "scripts": {
11
12
  "clean": "node ./scripts/clean.mjs",
@@ -1,93 +0,0 @@
1
- /**
2
- * @author NetFeez <netfeez.dev@gmail.com>.
3
- * @description Main CLI surface: dependency management commands, builds and config conversions.
4
- * @license Apache-2.0
5
- */
6
- import CLI from "./CLI.js";
7
- import OutputPolicy from "../task/OutputPolicy.js";
8
- import Flags from "./Flags.js";
9
- /** The flags accepted by every command of the CLI. **/
10
- export declare const options: Flags<{
11
- readonly flow: {
12
- readonly type: "string";
13
- readonly default: "depflow.yml";
14
- readonly aliases: readonly ["p", "f"];
15
- readonly description: "Path to the configuration file the command operates on.";
16
- };
17
- readonly watch: {
18
- readonly type: "boolean";
19
- readonly default: false;
20
- readonly aliases: readonly ["w"];
21
- readonly description: "Keeps watching the built files and rewrites their paths on every change.";
22
- };
23
- readonly cdn: {
24
- readonly type: "boolean";
25
- readonly default: false;
26
- readonly description: "Resolves the dependency paths to their CDN target instead of their local one.";
27
- };
28
- readonly verbose: {
29
- readonly type: "boolean";
30
- readonly default: false;
31
- readonly aliases: readonly ["v"];
32
- readonly description: "Streams the output of every command as it runs, attributed to the command that wrote it, instead of only reporting how each of them ended. The indentation of that output is lost, and the complete buffer of every command reaches the evidence file whether this flag is given or not.";
33
- };
34
- readonly silent: {
35
- readonly type: "boolean";
36
- readonly default: false;
37
- readonly description: "Says only what failed, one line per failed command. It silences the progress of DepFlow itself, such as \"Installing dependencies...\", and not the help, which belongs to the console interface. The exit status and the evidence file are the same as in any other mode.";
38
- };
39
- readonly decorate: {
40
- readonly type: "boolean";
41
- readonly default: true;
42
- readonly description: "Draws boxes, indentation, timestamps, levels and names around what is reported. --decorate=false leaves the content alone and keeps the color of the markers and the diagnostics, which carry information and are not decoration.";
43
- };
44
- }>;
45
- export declare class DepFlowCLI extends CLI {
46
- readonly configPath: string;
47
- protected readonly projectRoot: string;
48
- constructor(configPath?: string);
49
- /** Absolute path of the flow directory (`.depflow`) under the project root. **/
50
- protected get flowDirectory(): string;
51
- /**
52
- * The policy the run is presented through, built for the mode the flags asked for.
53
- * @param flags - The flags of the command being run.
54
- * @returns The policy of the run, never `null`: the evidence is written whether it is asked for or not.
55
- *
56
- * @remarks The policy is also what settles the channel the lifecycle of the CLI is reported through, so
57
- * every command asks for it first and reports through `policy.report`: a `silent` run that said
58
- * "Installing dependencies..." would not be silent, and an undecorated run would still draw boxes
59
- * around lines that carry nothing but what they say.
60
- *
61
- * @remarks A command reports through the policy and not through `this.out`, which belongs to the
62
- * console interface DepFlow was built on: the help, the prompt and the verdict of an invocation are
63
- * drawn by surfaces DepFlow does not own, and they stay visible in every mode.
64
- *
65
- * @example
66
- * ```ts
67
- * const policy = this.policy(flags);
68
- * const out = policy.report;
69
- * if (policy.decoration === 'on') out.group(Group.create('#FFB4DC'));
70
- * ```
71
- */
72
- protected policy(flags: DepFlowCLI.Options): OutputPolicy;
73
- commandAdd(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
74
- commandRemove(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
75
- commandInstall(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
76
- commandRun(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
77
- list(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
78
- rewritePaths(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
79
- commandSync(command: string, args: string[], flags?: DepFlowCLI.Options, caller?: OutputPolicy): Promise<void>;
80
- /**
81
- * Converts the depflow config file between JSON and YAML.
82
- * @param command - The invoked command name ('json-to-yaml' or 'yaml-to-json').
83
- * @param args - Optional output file path.
84
- * @param flags - The flags of the command being run, which settle how the conversion is reported.
85
- */
86
- convert(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
87
- }
88
- export declare namespace DepFlowCLI {
89
- type Exec = (this: DepFlowCLI, command: string, args: string[], flags: Options) => Promise<void> | void;
90
- /** The values of the flags accepted by the CLI. **/
91
- type Options = typeof options.infer;
92
- }
93
- export default DepFlowCLI;