@vltpkg/cli-sdk 1.0.0-rc.7 → 1.0.0-rc.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAyB5C,CAAA"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CA0B5C,CAAA"}
@@ -24,7 +24,8 @@ export const command = async (conf) => {
24
24
  // TODO: we should probably throw an error if the user
25
25
  // tries to install using either view=mermaid or view=gui
26
26
  const monorepo = conf.options.monorepo;
27
- const { add } = parseAddArgs(conf, monorepo);
27
+ const scurry = conf.options.scurry;
28
+ const { add } = parseAddArgs(conf, scurry, monorepo);
28
29
  const frozenLockfile = conf.options['frozen-lockfile'];
29
30
  const expectLockfile = conf.options['expect-lockfile'];
30
31
  const lockfileOnly = conf.options['lockfile-only'];
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAoBvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE;+CAC8B;CAC5C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACV,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACxB;gBACE,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,gFAAgF;aAChH;YACH,CAAC,CAAC,IAAI,CAAC;QACP,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;KACxB,CAAC;IACF,KAAK,EAAE,eAAe;CACiB,CAAA;AAEzC,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC5D,sDAAsD;IACtD,yDAAyD;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACtD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACtD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IAClD,qBAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CACzC;QACE,GAAG,IAAI,CAAC,OAAO;QACf,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;KACb,EACD,GAAG,CACJ,CAAA;IACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { Graph } from '@vltpkg/graph'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n/**\n * The resulting object of an install operation. To be used by the view impl.\n */\nexport type InstallResult = {\n /**\n * A queue of package IDs that need to be built after the install is complete.\n */\n buildQueue?: DepID[]\n /**\n * The resulting graph structure at the end of an install.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: i => ({\n ...(i.buildQueue?.length ?\n {\n buildQueue: i.buildQueue,\n message: `${i.buildQueue.length} packages that will need to be built, run \"vlt build\" to complete the install.`,\n }\n : null),\n graph: i.graph.toJSON(),\n }),\n human: InstallReporter,\n} as const satisfies Views<InstallResult>\n\nexport const command: CommandFn<InstallResult> = async conf => {\n // TODO: we should probably throw an error if the user\n // tries to install using either view=mermaid or view=gui\n const monorepo = conf.options.monorepo\n const { add } = parseAddArgs(conf, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const lockfileOnly = conf.options['lockfile-only']\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { buildQueue, graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n allowScripts,\n lockfileOnly,\n },\n add,\n )\n return { buildQueue, graph }\n}\n"]}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAoBvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE;+CAC8B;CAC5C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,I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AAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { Graph } from '@vltpkg/graph'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n/**\n * The resulting object of an install operation. To be used by the view impl.\n */\nexport type InstallResult = {\n /**\n * A queue of package IDs that need to be built after the install is complete.\n */\n buildQueue?: DepID[]\n /**\n * The resulting graph structure at the end of an install.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: i => ({\n ...(i.buildQueue?.length ?\n {\n buildQueue: i.buildQueue,\n message: `${i.buildQueue.length} packages that will need to be built, run \"vlt build\" to complete the install.`,\n }\n : null),\n graph: i.graph.toJSON(),\n }),\n human: InstallReporter,\n} as const satisfies Views<InstallResult>\n\nexport const command: CommandFn<InstallResult> = async conf => {\n // TODO: we should probably throw an error if the user\n // tries to install using either view=mermaid or view=gui\n const monorepo = conf.options.monorepo\n const scurry = conf.options.scurry\n const { add } = parseAddArgs(conf, scurry, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const lockfileOnly = conf.options['lockfile-only']\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { buildQueue, graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n allowScripts,\n lockfileOnly,\n },\n add,\n )\n return { buildQueue, graph }\n}\n"]}
@@ -13,8 +13,8 @@ export const views = {
13
13
  human: InstallReporter,
14
14
  };
15
15
  export const command = async (conf) => {
16
- const monorepo = conf.options.monorepo;
17
- const { remove } = parseRemoveArgs(conf, monorepo);
16
+ const { monorepo, scurry } = conf.options;
17
+ const { remove } = parseRemoveArgs(conf, scurry, monorepo);
18
18
  /* c8 ignore start */
19
19
  const allowScripts = conf.get('allow-scripts') ?
20
20
  String(conf.get('allow-scripts'))
@@ -1 +1 @@
1
- {"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAUvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;gEAC+C;CAC7D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,eAAe;CACmB,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAClD,qBAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAC/B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,EACjC,MAAM,CACP,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { uninstall } from '@vltpkg/graph'\nimport type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { parseRemoveArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\n\nexport type UninstallResult = {\n /**\n * The resulting graph structure at the end of an uninstall.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'uninstall',\n usage: '[package ...]',\n description: `The opposite of \\`vlt install\\`. Removes deps and updates\n vlt-lock.json and package.json appropriately.`,\n })\n\nexport const views = {\n json: i => i.graph.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<UninstallResult>\n\nexport const command: CommandFn<UninstallResult> = async conf => {\n const monorepo = conf.options.monorepo\n const { remove } = parseRemoveArgs(conf, monorepo)\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { graph } = await uninstall(\n { ...conf.options, allowScripts },\n remove,\n )\n return { graph }\n}\n"]}
1
+ {"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAUvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;gEAC+C;CAC7D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,eAAe;CACmB,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC9D,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC1D,qBAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAC/B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,EACjC,MAAM,CACP,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { uninstall } from '@vltpkg/graph'\nimport type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { parseRemoveArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\n\nexport type UninstallResult = {\n /**\n * The resulting graph structure at the end of an uninstall.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'uninstall',\n usage: '[package ...]',\n description: `The opposite of \\`vlt install\\`. Removes deps and updates\n vlt-lock.json and package.json appropriately.`,\n })\n\nexport const views = {\n json: i => i.graph.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<UninstallResult>\n\nexport const command: CommandFn<UninstallResult> = async conf => {\n const { monorepo, scurry } = conf.options\n const { remove } = parseRemoveArgs(conf, scurry, monorepo)\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { graph } = await uninstall(\n { ...conf.options, allowScripts },\n remove,\n )\n return { graph }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { PathScurry } from 'path-scurry';
1
2
  import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '@vltpkg/graph';
2
3
  import type { Monorepo } from '@vltpkg/workspaces';
3
4
  import type { LoadedConfig } from './config/index.ts';
@@ -17,6 +18,12 @@ export type WorkspaceTypes = {
17
18
  workspace?: string[];
18
19
  'workspace-group'?: string[];
19
20
  };
20
- export declare const parseAddArgs: (config: LoadedConfig, monorepo?: Monorepo) => ParsedAddArgs;
21
- export declare const parseRemoveArgs: (config: LoadedConfig, monorepo?: Monorepo) => ParsedRemoveArgs;
21
+ /**
22
+ * Parses the positional arguments into {@link AddImportersDependenciesMap}.
23
+ */
24
+ export declare const parseAddArgs: (config: LoadedConfig, scurry: PathScurry, monorepo?: Monorepo) => ParsedAddArgs;
25
+ /**
26
+ * Parses the positional arguments into {@link RemoveImportersDependenciesMap}.
27
+ */
28
+ export declare const parseRemoveArgs: (config: LoadedConfig, scurry: PathScurry, monorepo?: Monorepo) => ParsedRemoveArgs;
22
29
  //# sourceMappingURL=parse-add-remove-args.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-add-remove-args.d.ts","sourceRoot":"","sources":["../../src/parse-add-remove-args.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,eAAe,CAAA;AAKtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,K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zB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AAgED;;GAEG;AACH,eAAO,MAAM,YAAY,WACf,YAAY,UACZ,UAAU,aACP,QAAQ,KAClB,aAuCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,WAClB,YAAY,UACZ,UAAU,aACP,QAAQ,KAClB,gBAoBF,CAAA"}
@@ -1,12 +1,27 @@
1
- import { joinDepIDTuple } from '@vltpkg/dep-id';
2
1
  import { asDependency } from '@vltpkg/graph';
2
+ import { joinDepIDTuple } from '@vltpkg/dep-id';
3
3
  import { Spec } from '@vltpkg/spec';
4
4
  const rootDepID = joinDepIDTuple(['file', '.']);
5
+ /**
6
+ * Compute a DepID for the current working directory relative to the project
7
+ * root. Returns the root DepID if cwd is the project root, otherwise returns
8
+ * the computed DepID.
9
+ */
10
+ const getCwdDepID = (scurry) => {
11
+ const cwd = process.cwd();
12
+ const relPath = scurry.relativePosix(cwd);
13
+ // If cwd is the project root or outside it, return root DepID
14
+ if (!relPath || relPath.startsWith('..')) {
15
+ return rootDepID;
16
+ }
17
+ // Return a DepID for the nested folder (posix-style path)
18
+ return joinDepIDTuple(['file', relPath.split('\\').join('/')]);
19
+ };
5
20
  /**
6
21
  * Get the list of importers that are currently selected
7
22
  * in {@link WorkspaceTypes}.
8
23
  */
9
- const getImporters = (opts, monorepo) => {
24
+ const getWorkspaceImporters = (opts, monorepo) => {
10
25
  const res = new Set();
11
26
  // collects DepID references to any selected workspace
12
27
  if (monorepo) {
@@ -14,10 +29,6 @@ const getImporters = (opts, monorepo) => {
14
29
  res.add(ws.id);
15
30
  }
16
31
  }
17
- // if no references were found, default behavior is to point to project root
18
- if (!res.size) {
19
- res.add(rootDepID);
20
- }
21
32
  return res;
22
33
  };
23
34
  const getType = (opts) => opts['save-prod'] ? 'prod'
@@ -34,36 +45,58 @@ class AddImportersDependenciesMapImpl extends Map {
34
45
  class RemoveImportersDependenciesMapImpl extends Map {
35
46
  modifiedDependencies = false;
36
47
  }
37
- export const parseAddArgs = (config, monorepo) => {
48
+ /**
49
+ * Parses the positional arguments into {@link AddImportersDependenciesMap}.
50
+ */
51
+ export const parseAddArgs = (config, scurry, monorepo) => {
38
52
  const add = new AddImportersDependenciesMapImpl();
39
53
  const items = config.positionals;
40
54
  const type = getType(config.values);
41
- const importers = getImporters(config.values, monorepo);
55
+ const importers = getWorkspaceImporters(config.values, monorepo);
42
56
  const newDependencies = new Map();
43
57
  const specOptions = config.options;
44
58
  // nameless spec definitions will need to use their full
45
59
  // stringified spec result instead of their name in order
46
60
  // to have an unique key name in the resulting Map
47
61
  const getName = (s) => s.name === '(unknown)' ? s.spec : s.name;
62
+ // parses each positional argument into a Spec and
63
+ // adds it to the new dependencies Map
48
64
  for (const item of items) {
49
65
  const spec = Spec.parseArgs(item, specOptions);
50
66
  newDependencies.set(getName(spec), asDependency({ spec, type }));
51
67
  add.modifiedDependencies = true;
52
68
  }
69
+ // assigns the new dependencies to each selected workspace importer
53
70
  for (const importer of importers) {
54
71
  add.set(importer, newDependencies);
55
72
  }
73
+ // if no workspaces were selected, default to the cwd importer which
74
+ // can be either the root or a nested folder in case the user is installing
75
+ // from a subfolder that is also a file: type dependency
76
+ if (!importers.size) {
77
+ const cwdDepID = getCwdDepID(scurry);
78
+ add.set(cwdDepID, newDependencies);
79
+ }
56
80
  return {
57
81
  add,
58
82
  };
59
83
  };
60
- export const parseRemoveArgs = (config, monorepo) => {
84
+ /**
85
+ * Parses the positional arguments into {@link RemoveImportersDependenciesMap}.
86
+ */
87
+ export const parseRemoveArgs = (config, scurry, monorepo) => {
61
88
  const remove = new RemoveImportersDependenciesMapImpl();
62
- const importers = getImporters(config.values, monorepo);
89
+ const importers = getWorkspaceImporters(config.values, monorepo);
63
90
  for (const importer of importers) {
64
91
  remove.set(importer, new Set(config.positionals));
65
92
  remove.modifiedDependencies = true;
66
93
  }
94
+ // if no workspaces were selected, default to the cwd importer
95
+ if (!importers.size) {
96
+ const cwdDepID = getCwdDepID(scurry);
97
+ remove.set(cwdDepID, new Set(config.positionals));
98
+ remove.modifiedDependencies = true;
99
+ }
67
100
  return {
68
101
  remove,
69
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parse-add-remove-args.js","sourceRoot":"","sources":["../../src/parse-add-remove-args.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAM/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAyBnC,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAE/C;;;GAGG;AACH,MAAM,YAAY,GAAG,CACnB,IAAoB,EACpB,QAAmB,EACP,EAAE;IACd,MAAM,GAAG,GAAG,IAAI,GAAG,EAAS,CAAA;IAE5B,sDAAsD;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QAChB,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACd,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAC,IAAe,EAAsB,EAAE,CACtD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM;IAC1B,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAA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IAAI,EAAE,CAAC,CAAC,CAAA;QAChE,GAAG,CAAC,oBAAoB,GAAG,IAAI,CAAA;IACjC,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;IACpC,CAAC;IAED,OAAO;QACL,GAAG;KACJ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAoB,EACpB,QAAmB,EACD,EAAE;IACpB,MAAM,MAAM,GACV,IAAI,kCAAkC,EAAE,CAAA;IAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEvD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IACpC,CAAC;IAED,OAAO;QACL,MAAM;KACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { joinDepIDTuple } from '@vltpkg/dep-id'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '@vltpkg/graph'\nimport { asDependency } from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { Spec } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { LoadedConfig } from './config/index.ts'\n\nexport type ParsedAddArgs = {\n add: AddImportersDependenciesMap\n}\n\nexport type ParsedRemoveArgs = {\n remove: RemoveImportersDependenciesMap\n}\n\nexport type SaveTypes = {\n 'save-dev'?: boolean\n 'save-optional'?: boolean\n 'save-peer'?: boolean\n 'save-prod'?: boolean\n}\n\nexport type WorkspaceTypes = {\n workspace?: string[]\n 'workspace-group'?: string[]\n}\n\nconst rootDepID = joinDepIDTuple(['file', '.'])\n\n/**\n * Get the list of importers that are currently selected\n * in {@link WorkspaceTypes}.\n */\nconst getImporters = (\n opts: WorkspaceTypes,\n monorepo?: Monorepo,\n): Set<DepID> => {\n const res = new Set<DepID>()\n\n // collects DepID references to any selected workspace\n if (monorepo) {\n for (const ws of monorepo.filter(opts)) {\n res.add(ws.id)\n }\n }\n\n // if no references were found, default behavior is to point to project root\n if (!res.size) {\n res.add(rootDepID)\n }\n\n return res\n}\n\nconst getType = (opts: SaveTypes): DependencySaveType =>\n opts['save-prod'] ? 'prod'\n : opts['save-dev'] ? 'dev'\n : opts['save-peer'] ?\n opts['save-optional'] ?\n 'peerOptional'\n : 'peer'\n : opts['save-optional'] ? 'optional'\n : 'implicit'\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nexport const parseAddArgs = (\n config: LoadedConfig,\n monorepo?: Monorepo,\n): ParsedAddArgs => {\n const add: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const items = config.positionals\n const type = getType(config.values)\n const importers = getImporters(config.values, monorepo)\n const newDependencies = new Map<string, Dependency>()\n const specOptions: SpecOptions = config.options\n\n // nameless spec definitions will need to use their full\n // stringified spec result instead of their name in order\n // to have an unique key name in the resulting Map\n const getName = (s: Spec): string =>\n s.name === '(unknown)' ? s.spec : s.name\n\n for (const item of items) {\n const spec = Spec.parseArgs(item, specOptions)\n newDependencies.set(getName(spec), asDependency({ spec, type }))\n add.modifiedDependencies = true\n }\n\n for (const importer of importers) {\n add.set(importer, newDependencies)\n }\n\n return {\n add,\n }\n}\n\nexport const parseRemoveArgs = (\n config: LoadedConfig,\n monorepo?: Monorepo,\n): ParsedRemoveArgs => {\n const remove: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n const importers = getImporters(config.values, monorepo)\n\n for (const importer of importers) {\n remove.set(importer, new Set(config.positionals))\n remove.modifiedDependencies = true\n }\n\n return {\n remove,\n }\n}\n"]}
1
+ {"version":3,"file":"parse-add-remove-args.js","sourceRoot":"","sources":["../../src/parse-add-remove-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAiCnC,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAE/C;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAS,EAAE;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IACzC,8DAA8D;IAC9D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,0DAA0D;IAC1D,OAAO,cAAc,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChE,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAC5B,IAAoB,EACpB,QAAmB,EACP,EAAE;IACd,MAAM,GAAG,GAAG,IAAI,GAAG,EAAS,CAAA;IAE5B,sDAAsD;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,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AAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;QACpC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAA;IACpC,CAAC;IAED,OAAO;QACL,MAAM;KACP,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { asDependency } from '@vltpkg/graph'\nimport { joinDepIDTuple } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { LoadedConfig } from './config/index.ts'\n\nexport type ParsedAddArgs = {\n add: AddImportersDependenciesMap\n}\n\nexport type ParsedRemoveArgs = {\n remove: RemoveImportersDependenciesMap\n}\n\nexport type SaveTypes = {\n 'save-dev'?: boolean\n 'save-optional'?: boolean\n 'save-peer'?: boolean\n 'save-prod'?: boolean\n}\n\nexport type WorkspaceTypes = {\n workspace?: string[]\n 'workspace-group'?: string[]\n}\n\nconst rootDepID = joinDepIDTuple(['file', '.'])\n\n/**\n * Compute a DepID for the current working directory relative to the project\n * root. Returns the root DepID if cwd is the project root, otherwise returns\n * the computed DepID.\n */\nconst getCwdDepID = (scurry: PathScurry): DepID => {\n const cwd = process.cwd()\n const relPath = scurry.relativePosix(cwd)\n // If cwd is the project root or outside it, return root DepID\n if (!relPath || relPath.startsWith('..')) {\n return rootDepID\n }\n // Return a DepID for the nested folder (posix-style path)\n return joinDepIDTuple(['file', relPath.split('\\\\').join('/')])\n}\n\n/**\n * Get the list of importers that are currently selected\n * in {@link WorkspaceTypes}.\n */\nconst getWorkspaceImporters = (\n opts: WorkspaceTypes,\n monorepo?: Monorepo,\n): Set<DepID> => {\n const res = new Set<DepID>()\n\n // collects DepID references to any selected workspace\n if (monorepo) {\n for (const ws of monorepo.filter(opts)) {\n res.add(ws.id)\n }\n }\n\n return res\n}\n\nconst getType = (opts: SaveTypes): DependencySaveType =>\n opts['save-prod'] ? 'prod'\n : opts['save-dev'] ? 'dev'\n : opts['save-peer'] ?\n opts['save-optional'] ?\n 'peerOptional'\n : 'peer'\n : opts['save-optional'] ? 'optional'\n : 'implicit'\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\n/**\n * Parses the positional arguments into {@link AddImportersDependenciesMap}.\n */\nexport const parseAddArgs = (\n config: LoadedConfig,\n scurry: PathScurry,\n monorepo?: Monorepo,\n): ParsedAddArgs => {\n const add: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const items = config.positionals\n const type = getType(config.values)\n const importers = getWorkspaceImporters(config.values, monorepo)\n const newDependencies = new Map<string, Dependency>()\n const specOptions: SpecOptions = config.options\n\n // nameless spec definitions will need to use their full\n // stringified spec result instead of their name in order\n // to have an unique key name in the resulting Map\n const getName = (s: Spec): string =>\n s.name === '(unknown)' ? s.spec : s.name\n\n // parses each positional argument into a Spec and\n // adds it to the new dependencies Map\n for (const item of items) {\n const spec = Spec.parseArgs(item, specOptions)\n newDependencies.set(getName(spec), asDependency({ spec, type }))\n add.modifiedDependencies = true\n }\n\n // assigns the new dependencies to each selected workspace importer\n for (const importer of importers) {\n add.set(importer, newDependencies)\n }\n\n // if no workspaces were selected, default to the cwd importer which\n // can be either the root or a nested folder in case the user is installing\n // from a subfolder that is also a file: type dependency\n if (!importers.size) {\n const cwdDepID = getCwdDepID(scurry)\n add.set(cwdDepID, newDependencies)\n }\n\n return {\n add,\n }\n}\n\n/**\n * Parses the positional arguments into {@link RemoveImportersDependenciesMap}.\n */\nexport const parseRemoveArgs = (\n config: LoadedConfig,\n scurry: PathScurry,\n monorepo?: Monorepo,\n): ParsedRemoveArgs => {\n const remove: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n const importers = getWorkspaceImporters(config.values, monorepo)\n\n for (const importer of importers) {\n remove.set(importer, new Set(config.positionals))\n remove.modifiedDependencies = true\n }\n\n // if no workspaces were selected, default to the cwd importer\n if (!importers.size) {\n const cwdDepID = getCwdDepID(scurry)\n remove.set(cwdDepID, new Set(config.positionals))\n remove.modifiedDependencies = true\n }\n\n return {\n remove,\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/cli-sdk",
3
3
  "description": "The source for the vlt CLI",
4
- "version": "1.0.0-rc.7",
4
+ "version": "1.0.0-rc.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -43,30 +43,30 @@
43
43
  "ssri": "^12.0.0",
44
44
  "supports-color": "^10.2.0",
45
45
  "tar": "^7.4.3",
46
- "@vltpkg/config": "1.0.0-rc.7",
47
- "@vltpkg/dep-id": "1.0.0-rc.7",
48
- "@vltpkg/error-cause": "1.0.0-rc.7",
49
- "@vltpkg/dot-prop": "1.0.0-rc.7",
50
- "@vltpkg/git": "1.0.0-rc.7",
51
- "@vltpkg/graph": "1.0.0-rc.7",
52
- "@vltpkg/output": "1.0.0-rc.7",
53
- "@vltpkg/init": "1.0.0-rc.7",
54
- "@vltpkg/package-info": "1.0.0-rc.7",
55
- "@vltpkg/package-json": "1.0.0-rc.7",
56
- "@vltpkg/promise-spawn": "1.0.0-rc.7",
57
- "@vltpkg/query": "1.0.0-rc.7",
58
- "@vltpkg/run": "1.0.0-rc.7",
59
- "@vltpkg/registry-client": "1.0.0-rc.7",
60
- "@vltpkg/security-archive": "1.0.0-rc.7",
61
- "@vltpkg/server": "1.0.0-rc.7",
62
- "@vltpkg/rollback-remove": "1.0.0-rc.7",
63
- "@vltpkg/spec": "1.0.0-rc.7",
64
- "@vltpkg/types": "1.0.0-rc.7",
65
- "@vltpkg/vlt-json": "1.0.0-rc.7",
66
- "@vltpkg/vlx": "1.0.0-rc.7",
67
- "@vltpkg/url-open": "1.0.0-rc.7",
68
- "@vltpkg/xdg": "1.0.0-rc.7",
69
- "@vltpkg/workspaces": "1.0.0-rc.7"
46
+ "@vltpkg/config": "1.0.0-rc.8",
47
+ "@vltpkg/dep-id": "1.0.0-rc.8",
48
+ "@vltpkg/dot-prop": "1.0.0-rc.8",
49
+ "@vltpkg/error-cause": "1.0.0-rc.8",
50
+ "@vltpkg/graph": "1.0.0-rc.8",
51
+ "@vltpkg/git": "1.0.0-rc.8",
52
+ "@vltpkg/output": "1.0.0-rc.8",
53
+ "@vltpkg/package-info": "1.0.0-rc.8",
54
+ "@vltpkg/init": "1.0.0-rc.8",
55
+ "@vltpkg/package-json": "1.0.0-rc.8",
56
+ "@vltpkg/query": "1.0.0-rc.8",
57
+ "@vltpkg/promise-spawn": "1.0.0-rc.8",
58
+ "@vltpkg/registry-client": "1.0.0-rc.8",
59
+ "@vltpkg/rollback-remove": "1.0.0-rc.8",
60
+ "@vltpkg/server": "1.0.0-rc.8",
61
+ "@vltpkg/spec": "1.0.0-rc.8",
62
+ "@vltpkg/security-archive": "1.0.0-rc.8",
63
+ "@vltpkg/run": "1.0.0-rc.8",
64
+ "@vltpkg/types": "1.0.0-rc.8",
65
+ "@vltpkg/url-open": "1.0.0-rc.8",
66
+ "@vltpkg/vlx": "1.0.0-rc.8",
67
+ "@vltpkg/workspaces": "1.0.0-rc.8",
68
+ "@vltpkg/xdg": "1.0.0-rc.8",
69
+ "@vltpkg/vlt-json": "1.0.0-rc.8"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@eslint/js": "^9.34.0",