@vltpkg/cli-sdk 0.0.0-21 → 0.0.0-23
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/esm/commands/install/reporter.d.ts +1 -1
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +8 -10
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +15 -3
- package/dist/esm/commands/pack.d.ts.map +1 -1
- package/dist/esm/commands/pack.js +73 -16
- package/dist/esm/commands/pack.js.map +1 -1
- package/dist/esm/commands/pkg.d.ts +1 -1
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +6 -6
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +3 -2
- package/dist/esm/commands/publish.d.ts.map +1 -1
- package/dist/esm/commands/publish.js +78 -17
- package/dist/esm/commands/publish.js.map +1 -1
- package/dist/esm/commands/version.d.ts +8 -4
- package/dist/esm/commands/version.d.ts.map +1 -1
- package/dist/esm/commands/version.js +89 -20
- package/dist/esm/commands/version.js.map +1 -1
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +0 -1
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/output.d.ts +1 -1
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +1 -1
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/view.d.ts +1 -1
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +37 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,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H,MAAM;QACN,QAAQ,EAAE,WAAW,CAAC,MAAM;QAC5B,SAAS;QACT,MAAM;QACN,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,YAAY;QACZ,KAAK;KACN,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RegistryClient } from '@vltpkg/registry-client'\nimport type { CacheEntry } from '@vltpkg/registry-client'\nimport { run } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { packTarball } from '../pack-tarball.ts'\nimport type { Views } from '../view.ts'\nimport assert from 'node:assert'\nimport { asError } from '@vltpkg/types'\nimport { dirname } from 'node:path'\nimport prettyBytes from 'pretty-bytes'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'publish',\n usage: '',\n description: `Create a tarball from a package and publish it to the configured registry.\n \n This command will pack the package in the current directory or specified folder,\n and then upload it to the configured registry.`,\n options: {\n tag: {\n description: 'Publish the package with the given tag',\n value: '<tag>',\n },\n access: {\n description: 'Set access level (public or restricted)',\n value: '<level>',\n },\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n value: '<otp>',\n },\n },\n })\n\nexport type CommandResult = {\n id: string\n name: string\n version: string\n tag: string\n registry: string\n shasum?: string\n integrity?: string\n size: number\n access: string\n unpackedSize: number\n files: string[]\n}\n\nexport const views = {\n human: r => {\n const lines = [\n `📦 Package: ${r.id}`,\n `🏷️ Tag: ${r.tag}`,\n `📡 Registry: ${r.registry}`,\n `📁 ${r.files.length} Files`,\n ...r.files.map(f => ` - ${f}`),\n `📊 Package Size: ${prettyBytes(r.size)}`,\n `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,\n ]\n if (r.shasum) lines.push(`🔒 Shasum: ${r.shasum}`)\n if (r.integrity) lines.push(`🔐 Integrity: ${r.integrity}`)\n\n return lines.join('\\n')\n },\n json: r => r,\n} as const satisfies Views<CommandResult>\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const manifestPath = conf.options.packageJson.find()\n assert(manifestPath, 'No package.json found')\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n assert(\n !manifest.private,\n error('Package has been marked as private'),\n )\n\n const {\n tag = 'latest',\n access,\n registry,\n 'dry-run': dry = false,\n otp,\n } = conf.options\n const registryUrl = new URL(registry)\n\n const runOptions = {\n cwd: manifestDir,\n projectRoot: conf.projectRoot,\n packageJson: conf.options.packageJson,\n manifest,\n ignoreMissing: true,\n ignorePrePost: true,\n }\n\n await run({\n ...runOptions,\n arg0: 'prepublishOnly',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepublish',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepack',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepare',\n })\n\n const {\n name,\n version,\n tarballName,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n } = await packTarball(manifest, manifestDir, conf)\n\n await run({\n ...runOptions,\n arg0: 'postpack',\n })\n\n await run({\n ...runOptions,\n arg0: 'publish',\n })\n\n const publishMetadata = {\n _id: name,\n name,\n description: manifest.description || '',\n 'dist-tags': {\n [tag]: version,\n },\n versions: {\n [version]: {\n ...manifest,\n _id: `${name}@${version}`,\n _nodeVersion: process.versions.node,\n dist: {\n ...manifest.dist,\n integrity,\n shasum,\n tarball: new URL(`${name}/-/${tarballName}`, registryUrl)\n .href,\n },\n },\n },\n access,\n _attachments: {\n [tarballName]: {\n content_type: 'application/octet-stream',\n data: tarballData.toString('base64'),\n length: tarballData.length,\n },\n },\n }\n\n const rc = new RegistryClient(conf.options)\n const publishUrl = new URL(\n name.startsWith('@') ? name.replace('/', '%2F') : name,\n registryUrl,\n )\n\n if (!dry) {\n let response: CacheEntry\n try {\n response = await rc.request(publishUrl, {\n method: 'PUT',\n headers: {\n 'content-type': 'application/json',\n // These control what type of OTP auth flow is used\n 'npm-auth-type': 'web',\n 'npm-command': 'publish',\n },\n body: JSON.stringify(publishMetadata),\n otp,\n })\n } catch (err) {\n throw error('Failed to publish package', {\n cause: asError(err),\n })\n }\n\n if (response.statusCode !== 200 && response.statusCode !== 201) {\n throw error('Failed to publish package', {\n url: publishUrl,\n response,\n })\n }\n }\n\n await run({\n ...runOptions,\n arg0: 'postpublish',\n })\n\n return {\n id: `${name}@${version}`,\n name,\n version,\n tag,\n access,\n registry: registryUrl.origin,\n integrity,\n shasum,\n size: tarballData.length,\n unpackedSize,\n files,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAGrC,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;mDAGkC;IAC/C,OAAO,EAAE;QACP,GAAG,EAAE;YACH,WAAW,EAAE,wCAAwC;YACrD,KAAK,EAAE,OAAO;SACf;QACD,MAAM,EAAE;YACN,WAAW,EAAE,yCAAyC;YACtD,KAAK,EAAE,SAAS;SACjB;QACD,GAAG,EAAE;YACH,WA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AAC,eAAe,CAAC;gBACrC,GAAG;aACJ,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,KAAK,CAAC,2BAA2B,EAAE;gBACvC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;aACpB,CAAC,CAAA;QACJ,CAAC;QAED,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,IAAI,QAAQ,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC/D,MAAM,KAAK,CAAC,2BAA2B,EAAE;gBACvC,GAAG,EAAE,UAAU;gBACf,QAAQ;aACT,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,aAAa;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,EAAE,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;QACxB,IAAI;QACJ,OAAO;QACP,GAAG;QACH,MAAM;QACN,QAAQ,EAAE,WAAW,CAAC,MAAM;QAC5B,SAAS;QACT,MAAM;QACN,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,YAAY;QACZ,KAAK;KACN,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RegistryClient } from '@vltpkg/registry-client'\nimport type { CacheEntry } from '@vltpkg/registry-client'\nimport { run } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { packTarball } from '../pack-tarball.ts'\nimport type { Views } from '../view.ts'\nimport assert from 'node:assert'\nimport { asError } from '@vltpkg/types'\nimport { dirname, resolve } from 'node:path'\nimport prettyBytes from 'pretty-bytes'\nimport { actual } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport type { LoadedConfig } from '../config/index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'publish',\n usage: '',\n description: `Create a tarball from a package and publish it to the configured registry.\n \n This command will pack the package in the current directory or specified folder,\n and then upload it to the configured registry.`,\n options: {\n tag: {\n description: 'Publish the package with the given tag',\n value: '<tag>',\n },\n access: {\n description: 'Set access level (public or restricted)',\n value: '<level>',\n },\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n value: '<otp>',\n },\n 'publish-directory': {\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n value: '<path>',\n },\n },\n })\n\nexport type CommandResultSingle = {\n id: string\n name: string\n version: string\n tag: string\n registry: string\n shasum?: string\n integrity?: string\n size: number\n access: string\n unpackedSize: number\n files: string[]\n}\n\nexport type CommandResult =\n | CommandResultSingle\n | CommandResultSingle[]\n\nexport const views = {\n human: results => {\n const item = (r: CommandResultSingle) => {\n const lines = [\n `📦 Package: ${r.id}`,\n `🏷️ Tag: ${r.tag}`,\n `📡 Registry: ${r.registry}`,\n `📁 ${r.files.length} Files`,\n ...r.files.map(f => ` - ${f}`),\n `📊 Package Size: ${prettyBytes(r.size)}`,\n `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,\n ]\n if (r.shasum) lines.push(`🔒 Shasum: ${r.shasum}`)\n if (r.integrity) lines.push(`🔐 Integrity: ${r.integrity}`)\n return lines.join('\\n')\n }\n return Array.isArray(results) ?\n results.map(item).join('\\n\\n')\n : item(results)\n },\n json: r => r,\n} as const satisfies Views<CommandResult>\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const { options, projectRoot } = conf\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n const locations: string[] = []\n let single: string | null = null\n\n if (queryString) {\n const graph = actual.load({\n ...options,\n mainManifest: options.packageJson.read(projectRoot),\n monorepo: options.monorepo,\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n for (const node of nodes) {\n const { location } = node.toJSON()\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n locations.push(resolve(projectRoot, location))\n }\n } else if (paths?.length || groups?.length || recursive) {\n for (const workspace of options.monorepo ?? []) {\n locations.push(workspace.fullpath)\n }\n } else {\n single = options.packageJson.find(process.cwd()) ?? projectRoot\n }\n\n if (single) {\n return commandSingle(single, conf)\n }\n\n assert(\n locations.length > 0,\n error('No workspaces or query results found'),\n )\n\n const results: CommandResultSingle[] = []\n for (const location of locations) {\n results.push(await commandSingle(location, conf))\n }\n return results\n}\n\nconst commandSingle = async (\n location: string,\n conf: LoadedConfig,\n) => {\n const manifestPath = conf.options.packageJson.find(location)\n assert(manifestPath, 'No package.json found')\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n assert(\n !manifest.private,\n error('Package has been marked as private'),\n )\n\n const {\n tag = 'latest',\n access,\n registry,\n 'dry-run': dry = false,\n otp,\n } = conf.options\n const registryUrl = new URL(registry)\n\n const runOptions = {\n cwd: manifestDir,\n projectRoot: conf.projectRoot,\n packageJson: conf.options.packageJson,\n manifest,\n ignoreMissing: true,\n ignorePrePost: true,\n }\n\n await run({\n ...runOptions,\n arg0: 'prepublishOnly',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepublish',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepack',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepare',\n })\n\n const {\n name,\n version,\n tarballName,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n } = await packTarball(manifest, manifestDir, conf)\n\n await run({\n ...runOptions,\n arg0: 'postpack',\n })\n\n await run({\n ...runOptions,\n arg0: 'publish',\n })\n\n const publishMetadata = {\n _id: name,\n name,\n description: manifest.description || '',\n 'dist-tags': {\n [tag]: version,\n },\n versions: {\n [version]: {\n ...manifest,\n _id: `${name}@${version}`,\n _nodeVersion: process.versions.node,\n dist: {\n ...manifest.dist,\n integrity,\n shasum,\n tarball: new URL(`${name}/-/${tarballName}`, registryUrl)\n .href,\n },\n },\n },\n access,\n _attachments: {\n [tarballName]: {\n content_type: 'application/octet-stream',\n data: tarballData.toString('base64'),\n length: tarballData.length,\n },\n },\n }\n\n const rc = new RegistryClient(conf.options)\n const publishUrl = new URL(\n name.startsWith('@') ? name.replace('/', '%2F') : name,\n registryUrl,\n )\n\n if (!dry) {\n let response: CacheEntry\n try {\n response = await rc.request(publishUrl, {\n method: 'PUT',\n headers: {\n 'content-type': 'application/json',\n // These control what type of OTP auth flow is used\n 'npm-auth-type': 'web',\n 'npm-command': 'publish',\n },\n body: JSON.stringify(publishMetadata),\n otp,\n })\n } catch (err) {\n throw error('Failed to publish package', {\n cause: asError(err),\n })\n }\n\n if (response.statusCode !== 200 && response.statusCode !== 201) {\n throw error('Failed to publish package', {\n url: publishUrl,\n response,\n })\n }\n }\n\n await run({\n ...runOptions,\n arg0: 'postpublish',\n })\n\n return {\n id: `${name}@${version}`,\n name,\n version,\n tag,\n access,\n registry: registryUrl.origin,\n integrity,\n shasum,\n size: tarballData.length,\n unpackedSize,\n files,\n }\n}\n"]}
|
|
@@ -5,18 +5,22 @@ export type VersionOptions = {
|
|
|
5
5
|
tag?: boolean;
|
|
6
6
|
message?: string;
|
|
7
7
|
tagMessage?: string;
|
|
8
|
+
includeNameInCommit?: boolean;
|
|
9
|
+
includeNameInTag?: boolean;
|
|
8
10
|
};
|
|
9
|
-
export type
|
|
11
|
+
export type CommandResultSingle = {
|
|
12
|
+
name: string;
|
|
10
13
|
oldVersion: string;
|
|
11
14
|
newVersion: string;
|
|
12
15
|
dir: string;
|
|
13
16
|
committed?: string[];
|
|
14
17
|
tag?: string;
|
|
15
18
|
};
|
|
19
|
+
export type CommandResult = CommandResultSingle | CommandResultSingle[];
|
|
16
20
|
export declare const usage: CommandUsage;
|
|
17
21
|
export declare const views: {
|
|
18
|
-
readonly json: (result:
|
|
19
|
-
readonly human: (
|
|
22
|
+
readonly json: (result: CommandResult) => CommandResult;
|
|
23
|
+
readonly human: (results: CommandResult) => string;
|
|
20
24
|
};
|
|
21
|
-
export declare const command: CommandFn<
|
|
25
|
+
export declare const command: CommandFn<CommandResult>;
|
|
22
26
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ1D,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,mBAAmB,EAAE,CAAA;AA2LzB,eAAO,MAAM,KAAK,EAAE,YAanB,CAAA;AAED,eAAO,MAAM,KAAK;;;CAiBuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CA8D5C,CAAA"}
|
|
@@ -3,13 +3,15 @@ import { is as isGit, spawn as spawn_, isClean } from '@vltpkg/git';
|
|
|
3
3
|
import { error } from '@vltpkg/error-cause';
|
|
4
4
|
import { asError } from '@vltpkg/types';
|
|
5
5
|
import { commandUsage } from "../config/usage.js";
|
|
6
|
-
import { dirname } from 'node:path';
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
7
|
import assert from 'node:assert';
|
|
8
|
+
import { actual } from '@vltpkg/graph';
|
|
9
|
+
import { Query } from '@vltpkg/query';
|
|
8
10
|
const isValidVersionIncrement = (value) => versionIncrements.includes(value);
|
|
9
11
|
const version = async (conf, increment, cwd, {
|
|
10
12
|
// Hardcode happy path options for now.
|
|
11
13
|
// TODO: make these config definitions
|
|
12
|
-
prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = 'v%s', } = {}) => {
|
|
14
|
+
prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = 'v%s', includeNameInCommit = false, includeNameInTag = false, } = {}) => {
|
|
13
15
|
assert(increment, error('Version increment argument is required', {
|
|
14
16
|
code: 'EUSAGE',
|
|
15
17
|
validOptions: versionIncrements,
|
|
@@ -22,6 +24,9 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
22
24
|
const spawn = (args, opts) => spawn_(args, { cwd: manifestDir, ...opts });
|
|
23
25
|
const manifestDir = dirname(manifestPath);
|
|
24
26
|
const manifest = conf.options.packageJson.read(manifestDir);
|
|
27
|
+
assert(manifest.name, error('No name field found in package.json', {
|
|
28
|
+
path: manifestPath,
|
|
29
|
+
}));
|
|
25
30
|
assert(manifest.version, error('No version field found in package.json', {
|
|
26
31
|
path: manifestPath,
|
|
27
32
|
}));
|
|
@@ -53,6 +58,7 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
53
58
|
manifest.version = newVersion;
|
|
54
59
|
conf.options.packageJson.write(manifestDir, manifest);
|
|
55
60
|
const result = {
|
|
61
|
+
name: manifest.name,
|
|
56
62
|
oldVersion,
|
|
57
63
|
newVersion,
|
|
58
64
|
dir: manifestDir,
|
|
@@ -66,12 +72,19 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
66
72
|
if (!(await isClean({ cwd: conf.options.projectRoot }))) {
|
|
67
73
|
try {
|
|
68
74
|
// Check if there are changes other than package.json
|
|
69
|
-
const gitResult = await spawn([
|
|
75
|
+
const gitResult = await spawn([
|
|
76
|
+
'diff',
|
|
77
|
+
'--name-only',
|
|
78
|
+
'HEAD',
|
|
79
|
+
'--',
|
|
80
|
+
'.',
|
|
81
|
+
]);
|
|
70
82
|
const changedFiles = gitResult.stdout
|
|
71
83
|
.trim()
|
|
72
84
|
.split('\n')
|
|
73
|
-
.filter(Boolean)
|
|
74
|
-
|
|
85
|
+
.filter(Boolean)
|
|
86
|
+
.map(f => resolve(conf.options.projectRoot, f));
|
|
87
|
+
const nonPackageJsonChanges = changedFiles.filter(file => file !== resolve(manifestDir, 'package.json'));
|
|
75
88
|
assert(nonPackageJsonChanges.length === 0, error('Git working directory not clean. Please commit or stash your changes first.', { found: nonPackageJsonChanges }));
|
|
76
89
|
}
|
|
77
90
|
catch (err) {
|
|
@@ -86,9 +99,9 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
86
99
|
await spawn([
|
|
87
100
|
'commit',
|
|
88
101
|
'-m',
|
|
89
|
-
message.replace('%s', newVersion)
|
|
102
|
+
`${includeNameInCommit ? `${manifest.name}: ` : ''}${message.replace('%s', newVersion)}`,
|
|
90
103
|
]);
|
|
91
|
-
result.committed = files;
|
|
104
|
+
result.committed = files.map(f => resolve(manifestDir, f));
|
|
92
105
|
}
|
|
93
106
|
catch (err) {
|
|
94
107
|
throw error('Failed to commit version changes', {
|
|
@@ -99,12 +112,15 @@ prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = '
|
|
|
99
112
|
}
|
|
100
113
|
if (tag) {
|
|
101
114
|
try {
|
|
102
|
-
const tagName =
|
|
115
|
+
const tagName = (includeNameInTag ?
|
|
116
|
+
`${manifest.name.replace('/', '-').replace('@', '')}-`
|
|
117
|
+
: '') + `v${newVersion}`;
|
|
103
118
|
await spawn([
|
|
104
119
|
'tag',
|
|
105
120
|
tagName,
|
|
106
121
|
'-m',
|
|
107
|
-
|
|
122
|
+
(includeNameInTag ? `${manifest.name}: ` : '') +
|
|
123
|
+
tagMessage.replace('%s', newVersion),
|
|
108
124
|
]);
|
|
109
125
|
result.tag = tagName;
|
|
110
126
|
}
|
|
@@ -133,19 +149,72 @@ export const usage = () => {
|
|
|
133
149
|
};
|
|
134
150
|
export const views = {
|
|
135
151
|
json: result => result,
|
|
136
|
-
human:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
human: results => {
|
|
153
|
+
const item = (result) => {
|
|
154
|
+
let output = `${result.name}: v${result.newVersion}`;
|
|
155
|
+
if (result.committed) {
|
|
156
|
+
output += ` +commit`;
|
|
157
|
+
}
|
|
158
|
+
if (result.tag) {
|
|
159
|
+
output += ` +tag`;
|
|
160
|
+
}
|
|
161
|
+
return output;
|
|
162
|
+
};
|
|
163
|
+
return Array.isArray(results) ?
|
|
164
|
+
results.map(item).join('\n')
|
|
165
|
+
: item(results);
|
|
145
166
|
},
|
|
146
167
|
};
|
|
147
168
|
export const command = async (conf) => {
|
|
148
|
-
const { positionals } = conf;
|
|
149
|
-
|
|
169
|
+
const { positionals, options, projectRoot } = conf;
|
|
170
|
+
const queryString = conf.get('scope');
|
|
171
|
+
const paths = conf.get('workspace');
|
|
172
|
+
const groups = conf.get('workspace-group');
|
|
173
|
+
const recursive = conf.get('recursive');
|
|
174
|
+
const locations = [];
|
|
175
|
+
let single = null;
|
|
176
|
+
if (queryString) {
|
|
177
|
+
const graph = actual.load({
|
|
178
|
+
...options,
|
|
179
|
+
mainManifest: options.packageJson.read(projectRoot),
|
|
180
|
+
monorepo: options.monorepo,
|
|
181
|
+
loadManifests: false,
|
|
182
|
+
});
|
|
183
|
+
const query = new Query({
|
|
184
|
+
graph,
|
|
185
|
+
specOptions: conf.options,
|
|
186
|
+
securityArchive: undefined,
|
|
187
|
+
});
|
|
188
|
+
const { nodes } = await query.search(queryString, {
|
|
189
|
+
signal: new AbortController().signal,
|
|
190
|
+
});
|
|
191
|
+
for (const node of nodes) {
|
|
192
|
+
const { location } = node.toJSON();
|
|
193
|
+
assert(location, error(`node ${node.id} has no location`, {
|
|
194
|
+
found: node,
|
|
195
|
+
}));
|
|
196
|
+
locations.push(resolve(projectRoot, location));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (paths?.length || groups?.length || recursive) {
|
|
200
|
+
for (const workspace of options.monorepo ?? []) {
|
|
201
|
+
locations.push(workspace.fullpath);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
single = options.packageJson.find(process.cwd()) ?? projectRoot;
|
|
206
|
+
}
|
|
207
|
+
if (single) {
|
|
208
|
+
return version(conf, positionals[0], single);
|
|
209
|
+
}
|
|
210
|
+
assert(locations.length > 0, error('No workspaces or query results found'));
|
|
211
|
+
const results = [];
|
|
212
|
+
for (const location of locations) {
|
|
213
|
+
results.push(await version(conf, positionals[0], location, {
|
|
214
|
+
includeNameInCommit: true,
|
|
215
|
+
includeNameInTag: true,
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
return results;
|
|
150
219
|
};
|
|
151
220
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,IAAI,YAAY,EACrB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,EAAE,IAAI,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;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O,MAAM,CAAA;IACf,CAAC;CACsC,CAAA;AAEzC,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC5D,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC5B,OAAO,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA","sourcesContent":["import {\n inc,\n parse as parseVersion,\n versionIncrements,\n} from '@vltpkg/semver'\nimport type { IncrementType } from '@vltpkg/semver'\nimport { is as isGit, spawn as spawn_, isClean } from '@vltpkg/git'\nimport type { GitOptions } from '@vltpkg/git'\nimport { error } from '@vltpkg/error-cause'\nimport { asError } from '@vltpkg/types'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { ParsedConfig } from '../config/index.ts'\nimport { dirname } from 'node:path'\nimport assert from 'node:assert'\n\nexport type VersionOptions = {\n prereleaseId?: string\n commit?: boolean\n tag?: boolean\n message?: string\n tagMessage?: string\n}\n\nexport type VersionResult = {\n oldVersion: string\n newVersion: string\n dir: string\n committed?: string[]\n tag?: string\n}\n\nconst isValidVersionIncrement = (\n value: string,\n): value is IncrementType =>\n versionIncrements.includes(value as IncrementType)\n\nconst version = async (\n conf: ParsedConfig,\n increment: string | undefined,\n cwd: string,\n {\n // Hardcode happy path options for now.\n // TODO: make these config definitions\n prereleaseId = 'pre',\n commit = true,\n tag = true,\n message = 'v%s',\n tagMessage = 'v%s',\n }: VersionOptions = {},\n): Promise<VersionResult> => {\n assert(\n increment,\n error('Version increment argument is required', {\n code: 'EUSAGE',\n validOptions: versionIncrements,\n }),\n )\n\n const manifestPath = conf.options.packageJson.find(cwd)\n assert(\n manifestPath,\n error('No package.json found', {\n code: 'ENOENT',\n path: cwd,\n }),\n )\n\n const spawn = (args: string[], opts?: GitOptions) =>\n spawn_(args, { cwd: manifestDir, ...opts })\n\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n assert(\n manifest.version,\n error('No version field found in package.json', {\n path: manifestPath,\n }),\n )\n\n const oldVersion = manifest.version\n let newVersion: string\n\n // Check if increment is a valid semver version string\n const parsedIncrement = parseVersion(increment)\n if (parsedIncrement) {\n newVersion = parsedIncrement.toString()\n } else if (isValidVersionIncrement(increment)) {\n // Use semver increment\n const incrementType = increment\n try {\n const result = inc(oldVersion, incrementType, prereleaseId)\n newVersion = result.toString()\n } catch (err) {\n throw error(\n `Failed to increment version from ${oldVersion} with ${increment}`,\n { version: oldVersion, wanted: increment, cause: err },\n )\n }\n } else {\n throw error(\n `Invalid version increment: ${increment}. Must be a valid semver version or one of: major, minor, patch, premajor, preminor, prepatch, prerelease`,\n {\n found: increment,\n validOptions: versionIncrements,\n },\n )\n }\n\n // Update the manifest\n manifest.version = newVersion\n conf.options.packageJson.write(manifestDir, manifest)\n\n const result: VersionResult = {\n oldVersion,\n newVersion,\n dir: manifestDir,\n }\n\n // Handle git operations if we're in a git repository\n if (\n /* c8 ignore next -- commit and tag are always true for now */\n (commit || tag) &&\n (await isGit({ cwd: conf.options.projectRoot }))\n ) {\n // Check for uncommitted changes (excluding package.json since we just modified it)\n if (!(await isClean({ cwd: conf.options.projectRoot }))) {\n try {\n // Check if there are changes other than package.json\n const gitResult = await spawn(['diff', '--name-only', 'HEAD'])\n const changedFiles = gitResult.stdout\n .trim()\n .split('\\n')\n .filter(Boolean)\n const nonPackageJsonChanges = changedFiles.filter(\n file => file !== 'package.json',\n )\n assert(\n nonPackageJsonChanges.length === 0,\n error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n { found: nonPackageJsonChanges },\n ),\n )\n } catch (err) {\n throw error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n asError(err),\n )\n }\n }\n\n if (commit) {\n try {\n // Stage package.json\n const files = ['package.json']\n await spawn(['add', ...files])\n await spawn([\n 'commit',\n '-m',\n message.replace('%s', newVersion),\n ])\n result.committed = files\n } catch (err) {\n throw error('Failed to commit version changes', {\n version: newVersion,\n cause: err,\n })\n }\n }\n\n if (tag) {\n try {\n const tagName = `v${newVersion}`\n await spawn([\n 'tag',\n tagName,\n '-m',\n tagMessage.replace('%s', newVersion),\n ])\n result.tag = tagName\n } catch (err) {\n throw error('Failed to create git tag', {\n version: newVersion,\n cause: err,\n })\n }\n }\n }\n\n return result\n}\n\nexport const usage: CommandUsage = () => {\n return commandUsage({\n command: 'version',\n usage:\n '[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]',\n description: `Bump a package's version.\n\n Run in a package directory to bump the version and write the new data back to package.json.\n\n The \\`<newversion>\\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).\n\n If run in a git repository, it will also create a version commit and tag.`,\n })\n}\n\nexport const views = {\n json: result => result,\n human: result => {\n let output = `v${result.newVersion}`\n if (result.committed) {\n output += ` +commit`\n }\n if (result.tag) {\n output += ` +tag`\n }\n return output\n },\n} as const satisfies Views<VersionResult>\n\nexport const command: CommandFn<VersionResult> = async conf => {\n const { positionals } = conf\n return version(conf, positionals[0], process.cwd())\n}\n"]}
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,IAAI,YAAY,EACrB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,EAAE,IAAI,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAA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CAAC;QACxD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;YAC/C,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,WAAW,CAAA;IACjE,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;IAC9C,CAAC;IAED,MAAM,CACJ,SAAS,CAAC,MAAM,GAAG,CAAC,EACpB,KAAK,CAAC,sCAAsC,CAAC,CAC9C,CAAA;IAED,MAAM,OAAO,GAA0B,EAAE,CAAA;IACzC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CACV,MAAM,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE;YAC5C,mBAAmB,EAAE,IAAI;YACzB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import {\n inc,\n parse as parseVersion,\n versionIncrements,\n} from '@vltpkg/semver'\nimport type { IncrementType } from '@vltpkg/semver'\nimport { is as isGit, spawn as spawn_, isClean } from '@vltpkg/git'\nimport type { GitOptions } from '@vltpkg/git'\nimport { error } from '@vltpkg/error-cause'\nimport { asError } from '@vltpkg/types'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { ParsedConfig } from '../config/index.ts'\nimport { dirname, resolve } from 'node:path'\nimport assert from 'node:assert'\nimport { actual } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\n\nexport type VersionOptions = {\n prereleaseId?: string\n commit?: boolean\n tag?: boolean\n message?: string\n tagMessage?: string\n includeNameInCommit?: boolean\n includeNameInTag?: boolean\n}\n\nexport type CommandResultSingle = {\n name: string\n oldVersion: string\n newVersion: string\n dir: string\n committed?: string[]\n tag?: string\n}\n\nexport type CommandResult =\n | CommandResultSingle\n | CommandResultSingle[]\n\nconst isValidVersionIncrement = (\n value: string,\n): value is IncrementType =>\n versionIncrements.includes(value as IncrementType)\n\nconst version = async (\n conf: ParsedConfig,\n increment: string | undefined,\n cwd: string,\n {\n // Hardcode happy path options for now.\n // TODO: make these config definitions\n prereleaseId = 'pre',\n commit = true,\n tag = true,\n message = 'v%s',\n tagMessage = 'v%s',\n includeNameInCommit = false,\n includeNameInTag = false,\n }: VersionOptions = {},\n): Promise<CommandResultSingle> => {\n assert(\n increment,\n error('Version increment argument is required', {\n code: 'EUSAGE',\n validOptions: versionIncrements,\n }),\n )\n\n const manifestPath = conf.options.packageJson.find(cwd)\n assert(\n manifestPath,\n error('No package.json found', {\n code: 'ENOENT',\n path: cwd,\n }),\n )\n\n const spawn = (args: string[], opts?: GitOptions) =>\n spawn_(args, { cwd: manifestDir, ...opts })\n\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n assert(\n manifest.name,\n error('No name field found in package.json', {\n path: manifestPath,\n }),\n )\n assert(\n manifest.version,\n error('No version field found in package.json', {\n path: manifestPath,\n }),\n )\n\n const oldVersion = manifest.version\n let newVersion: string\n\n // Check if increment is a valid semver version string\n const parsedIncrement = parseVersion(increment)\n if (parsedIncrement) {\n newVersion = parsedIncrement.toString()\n } else if (isValidVersionIncrement(increment)) {\n // Use semver increment\n const incrementType = increment\n try {\n const result = inc(oldVersion, incrementType, prereleaseId)\n newVersion = result.toString()\n } catch (err) {\n throw error(\n `Failed to increment version from ${oldVersion} with ${increment}`,\n { version: oldVersion, wanted: increment, cause: err },\n )\n }\n } else {\n throw error(\n `Invalid version increment: ${increment}. Must be a valid semver version or one of: major, minor, patch, premajor, preminor, prepatch, prerelease`,\n {\n found: increment,\n validOptions: versionIncrements,\n },\n )\n }\n\n // Update the manifest\n manifest.version = newVersion\n conf.options.packageJson.write(manifestDir, manifest)\n\n const result: CommandResultSingle = {\n name: manifest.name,\n oldVersion,\n newVersion,\n dir: manifestDir,\n }\n\n // Handle git operations if we're in a git repository\n if (\n /* c8 ignore next -- commit and tag are always true for now */\n (commit || tag) &&\n (await isGit({ cwd: conf.options.projectRoot }))\n ) {\n // Check for uncommitted changes (excluding package.json since we just modified it)\n if (!(await isClean({ cwd: conf.options.projectRoot }))) {\n try {\n // Check if there are changes other than package.json\n const gitResult = await spawn([\n 'diff',\n '--name-only',\n 'HEAD',\n '--',\n '.',\n ])\n const changedFiles = gitResult.stdout\n .trim()\n .split('\\n')\n .filter(Boolean)\n .map(f => resolve(conf.options.projectRoot, f))\n const nonPackageJsonChanges = changedFiles.filter(\n file => file !== resolve(manifestDir, 'package.json'),\n )\n assert(\n nonPackageJsonChanges.length === 0,\n error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n { found: nonPackageJsonChanges },\n ),\n )\n } catch (err) {\n throw error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n asError(err),\n )\n }\n }\n\n if (commit) {\n try {\n // Stage package.json\n const files = ['package.json']\n await spawn(['add', ...files])\n await spawn([\n 'commit',\n '-m',\n `${includeNameInCommit ? `${manifest.name}: ` : ''}${message.replace(\n '%s',\n newVersion,\n )}`,\n ])\n result.committed = files.map(f => resolve(manifestDir, f))\n } catch (err) {\n throw error('Failed to commit version changes', {\n version: newVersion,\n cause: err,\n })\n }\n }\n\n if (tag) {\n try {\n const tagName =\n (includeNameInTag ?\n `${manifest.name.replace('/', '-').replace('@', '')}-`\n : '') + `v${newVersion}`\n await spawn([\n 'tag',\n tagName,\n '-m',\n (includeNameInTag ? `${manifest.name}: ` : '') +\n tagMessage.replace('%s', newVersion),\n ])\n result.tag = tagName\n } catch (err) {\n throw error('Failed to create git tag', {\n version: newVersion,\n cause: err,\n })\n }\n }\n }\n\n return result\n}\n\nexport const usage: CommandUsage = () => {\n return commandUsage({\n command: 'version',\n usage:\n '[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]',\n description: `Bump a package's version.\n\n Run in a package directory to bump the version and write the new data back to package.json.\n\n The \\`<newversion>\\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).\n\n If run in a git repository, it will also create a version commit and tag.`,\n })\n}\n\nexport const views = {\n json: result => result,\n human: results => {\n const item = (result: CommandResultSingle) => {\n let output = `${result.name}: v${result.newVersion}`\n if (result.committed) {\n output += ` +commit`\n }\n if (result.tag) {\n output += ` +tag`\n }\n return output\n }\n return Array.isArray(results) ?\n results.map(item).join('\\n')\n : item(results)\n },\n} as const satisfies Views<CommandResult>\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const { positionals, options, projectRoot } = conf\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n const locations: string[] = []\n let single: string | null = null\n\n if (queryString) {\n const graph = actual.load({\n ...options,\n mainManifest: options.packageJson.read(projectRoot),\n monorepo: options.monorepo,\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n for (const node of nodes) {\n const { location } = node.toJSON()\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n locations.push(resolve(projectRoot, location))\n }\n } else if (paths?.length || groups?.length || recursive) {\n for (const workspace of options.monorepo ?? []) {\n locations.push(workspace.fullpath)\n }\n } else {\n single = options.packageJson.find(process.cwd()) ?? projectRoot\n }\n\n if (single) {\n return version(conf, positionals[0], single)\n }\n\n assert(\n locations.length > 0,\n error('No workspaces or query results found'),\n )\n\n const results: CommandResultSingle[] = []\n for (const location of locations) {\n results.push(\n await version(conf, positionals[0], location, {\n includeNameInCommit: true,\n includeNameInTag: true,\n }),\n )\n }\n return results\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAOd,CAAA;AAEV,eAAO,MAAM,aAAa,cAKjB,CAAA;AA+CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2OH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8MP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAOd,CAAA;AAEV,eAAO,MAAM,aAAa,cAKjB,CAAA;AA+CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2OH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8MP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
|
|
@@ -570,7 +570,6 @@ export const definition = j
|
|
|
570
570
|
'publish-directory': {
|
|
571
571
|
hint: 'path',
|
|
572
572
|
description: `Directory to use for pack and publish operations instead of the current directory.
|
|
573
|
-
Similar to pnpm's publishConfig.directory feature.
|
|
574
573
|
The directory must exist and nothing will be copied to it.`,
|
|
575
574
|
},
|
|
576
575
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW;AACtB,uCAAuC;AACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,6DAA6D;IAC7D,sDAAsD;IACxD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;QACxB,6BAA6B;QAC/B,CAAC,CAAC,MAAM,CAAA;AAEV,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,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const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n Similar to pnpm's publishConfig.directory feature.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW;AACtB,uCAAuC;AACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,6DAA6D;IAC7D,sDAAsD;IACxD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;QACxB,6BAA6B;QAC/B,CAAC,CAAC,MAAM,CAAA;AAEV,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM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AA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
package/dist/esm/output.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type StyleTextFn = (format: Parameters<typeof utilStyleText>[0], s: string) => s
|
|
|
8
8
|
export declare let styleTextStdout: StyleTextFn;
|
|
9
9
|
export declare let styleTextStderr: StyleTextFn;
|
|
10
10
|
export declare const getView: <T>(conf: LoadedConfig, views?: Views<T>) => View<T>;
|
|
11
|
-
export type OnDone<T> = (
|
|
11
|
+
export type OnDone<T> = (result: T) => Promise<unknown>;
|
|
12
12
|
/**
|
|
13
13
|
* Main export. Run the command appropriately, displaying output using
|
|
14
14
|
* the user-requested view, or the default if the user requested a view
|
package/dist/esm/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,IAAI,aAAa,EAC3B,MAAM,WAAW,CAAA;AAGlB,OAAO,K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,WAAyB,CAAA;AACrD,eAAO,IAAI,eAAe,EAAE,WAAyB,CAAA;AAKrD,eAAO,MAAM,OAAO,GAAI,CAAC,QACjB,YAAY,UACV,KAAK,CAAC,CAAC,CAAC,KACf,IAAI,CAAC,CAAC,CA2BR,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAsCvD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,cACvB,OAAO,CAAC,CAAC,CAAC,QAChB,YAAY,cACP;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,kBAoD7B,CAAA"}
|
package/dist/esm/output.js
CHANGED
package/dist/esm/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,SAAS,IAAI,aAAa,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,aAAa,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC5C,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9D,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IAC/B,oBAAoB;IACpB,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC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,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;QACd,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAA;QAEtB,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE;YAC3B,GAAG,aAAa;YAChB,MAAM,EAAE,WAAW;SACpB,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { WriteStream } from 'node:tty'\nimport {\n formatWithOptions,\n styleText as utilStyleText,\n} from 'node:util'\nimport { createSupportsColor } from 'supports-color'\nimport { defaultView } from './config/definition.ts'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { Command } from './index.ts'\nimport { printErr, formatOptions } from './print-err.ts'\nimport type { View, ViewOptions, Views } from './view.ts'\nimport { isViewClass } from './view.ts'\n\nconst supportsColor = (stream: WriteStream) => {\n const res = createSupportsColor(stream, { sniffFlags: false })\n if (res === false) return false\n /* c8 ignore next */\n return res.level > 0\n}\n\n// eslint-disable-next-line no-console\nexport const stdout = (...args: unknown[]) => console.log(...args)\n// eslint-disable-next-line no-console\nexport const stderr = (...args: unknown[]) => console.error(...args)\n\ntype StyleTextFn = (\n format: Parameters<typeof utilStyleText>[0],\n s: string,\n) => string\n\n/* c8 ignore start */\nconst styleText: StyleTextFn = (f, s) =>\n utilStyleText(f, s, { validateStream: false })\n/* c8 ignore stop */\n\n// TODO: stop exporting mutable variables once exec output is refactored\n/* c8 ignore start */\nexport let styleTextStdout: StyleTextFn = (_, s) => s\nexport let styleTextStderr: StyleTextFn = (_, s) => s\n/* c8 ignore stop */\n\nconst identity = <T>(x: T): T => x\n\nexport const getView = <T>(\n conf: LoadedConfig,\n views?: Views<T>,\n): View<T> => {\n const viewName = conf.values.view\n\n const viewFn =\n viewName === 'inspect' ? identity\n : viewName === 'silent' ? () => undefined\n : typeof views === 'function' ? views\n : views && typeof views === 'object' ? views[viewName]\n : identity\n\n // if the user specified a view that doesn't exist, then set it back to the\n // default, and try again. This will fall back to identity if it's also\n // missing. We also always treat 'json' as a valid view that falls back to\n // identity. This allows the explicit use of `--view=json` to work even\n // when the default view is `human`.\n if (\n !viewFn &&\n conf.values.view !== defaultView &&\n conf.values.view !== 'json' &&\n conf.values.view !== 'silent'\n ) {\n conf.values.view = defaultView\n process.env.VLT_VIEW = defaultView\n return getView(conf, views)\n }\n\n return viewFn ?? identity\n}\n\nexport type OnDone<T> = (result: T) => Promise<unknown>\n\n/**\n * If the view is a View class, then instantiate and start it.\n * If it's a view function, then just define the onDone method.\n */\nconst startView = <T>(\n conf: LoadedConfig,\n opts: ViewOptions,\n views?: Views<T>,\n { start }: { start: number } = { start: Date.now() },\n): {\n onDone: OnDone<T>\n onError?: (err: unknown) => void\n} => {\n const View = getView<T>(conf, views)\n\n if (isViewClass(View)) {\n const view = new View(opts, conf)\n view.start()\n return {\n async onDone(r) {\n return view.done(r, { time: Date.now() - start })\n },\n onError(err) {\n view.error(err)\n },\n }\n }\n\n return {\n async onDone(r) {\n if (r === undefined) return\n return View(r, opts, conf)\n },\n }\n}\n\n/**\n * Main export. Run the command appropriately, displaying output using\n * the user-requested view, or the default if the user requested a view\n * that is not defined for this command.\n */\nexport const outputCommand = async <T>(\n cliCommand: Command<T>,\n conf: LoadedConfig,\n { start }: { start: number } = { start: Date.now() },\n) => {\n const { usage, views, command } = cliCommand\n\n if (conf.values.help) {\n return stdout(usage().usage())\n }\n\n const stdoutColor =\n conf.values.color ?? supportsColor(process.stdout)\n const stderrColor =\n conf.values.color ?? supportsColor(process.stderr)\n\n /* c8 ignore start */\n if (stdoutColor) styleTextStdout = styleText\n if (stderrColor) styleTextStderr = styleText\n /* c8 ignore stop */\n\n const { onDone, onError } = startView(\n conf,\n // assume views will always output to stdout so use color support from there\n { colors: stdoutColor },\n views,\n { start },\n )\n\n try {\n const output = await onDone(await command(conf))\n if (output !== undefined && conf.values.view !== 'silent') {\n stdout(\n conf.values.view === 'json' ?\n JSON.stringify(output, null, 2)\n : formatWithOptions(\n {\n ...formatOptions,\n colors: stdoutColor,\n },\n output,\n ),\n )\n }\n } catch (err) {\n onError?.(err)\n process.exitCode ||= 1\n\n printErr(err, usage, stderr, {\n ...formatOptions,\n colors: stderrColor,\n })\n\n process.exit(process.exitCode)\n }\n}\n"]}
|
package/dist/esm/view.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class ViewClass<T = unknown> {
|
|
|
20
20
|
start(): void;
|
|
21
21
|
done(_result: T, _opts: {
|
|
22
22
|
time: number;
|
|
23
|
-
}): unknown
|
|
23
|
+
}): Promise<unknown>;
|
|
24
24
|
error(_err: unknown): void;
|
|
25
25
|
}
|
|
26
26
|
export type ViewFn<T = unknown> = (result: T, options: ViewOptions, conf: LoadedConfig) => unknown;
|
package/dist/esm/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,qBAAa,SAAS,CAAC,CAAC,GAAG,OAAO;IAChC,OAAO,EAAE,WAAW,CAAA;IACpB,MAAM,EAAE,YAAY,CAAA;gBAER,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY;IAQtD,KAAK;
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE9C;;;;;;;;;;GAUG;AACH,qBAAa,SAAS,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