@vltpkg/cli-sdk 0.0.0-17 → 0.0.0-18

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.
@@ -21,17 +21,17 @@ export const usage = () => commandUsage({
21
21
  export const views = {
22
22
  human: r => {
23
23
  const lines = [
24
- `📦 ${r.name}@${r.version}`,
25
- `📄 ${r.filename}`,
26
- `📁 ${r.files.length} files`,
24
+ `📦 Package: ${r.id}`,
25
+ `📄 File: ${r.filename}`,
26
+ `📁 ${r.files.length} Files`,
27
27
  ...r.files.map(f => ` - ${f}`),
28
- `📊 package size: ${prettyBytes(r.size)}`,
29
- `📂 unpacked size: ${prettyBytes(r.unpackedSize)}`,
28
+ `📊 Package Size: ${prettyBytes(r.size)}`,
29
+ `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,
30
30
  ];
31
31
  if (r.shasum)
32
- lines.push(`🔒 shasum: ${r.shasum}`);
32
+ lines.push(`🔒 Shasum: ${r.shasum}`);
33
33
  if (r.integrity)
34
- lines.push(`🔐 integrity: ${r.integrity}`);
34
+ lines.push(`🔐 Integrity: ${r.integrity}`);
35
35
  return lines.join('\n');
36
36
  },
37
37
  json: r => r,
@@ -1 +1 @@
1
- {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,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,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,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QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAE3D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG;QACjB,GAAG,EAAE,WAAW;QAChB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;QACrC,QAAQ;QACR,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,IAAI;KACpB,CAAA;IAED,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;IAEF,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;IAEF,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,KAAK,EACL,SAAS,EACT,MAAM,GACP,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;IAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,UAAU;KACjB,CAAC,CAAA;IAEF,OAAO;QACL,EAAE,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;QACxB,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,KAAK;QACL,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,YAAY;QACZ,MAAM;QACN,SAAS;KACV,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport assert from 'node:assert'\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 prettyBytes from 'pretty-bytes'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pack',\n usage: '',\n description: `Create a tarball from a package in the current directory or specified folder.\n \n The tarball will be saved to the current directory with the name\n <name>-<version>.tgz.`,\n options: {\n 'dry-run': {\n description:\n 'Show what would be packed without creating a tarball',\n },\n },\n })\n\ntype CommandResult = {\n id: string\n name: string\n version: string\n filename: string\n files: string[]\n size: number\n unpackedSize: number\n shasum?: string\n integrity?: string\n}\n\nexport const views = {\n human: r => {\n const lines = [\n `📦 ${r.name}@${r.version}`,\n `📄 ${r.filename}`,\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 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 const isDryRun = conf.options['dry-run']\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: 'prepack',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepare',\n })\n\n const {\n name,\n version,\n filename,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n } = await packTarball(manifest, manifestDir, conf)\n\n if (!isDryRun) {\n await writeFile(join(manifestDir, filename), tarballData)\n }\n\n await run({\n ...runOptions,\n arg0: 'postpack',\n })\n\n return {\n id: `${name}@${version}`,\n name,\n version,\n filename,\n files,\n size: tarballData.length,\n unpackedSize,\n shasum,\n integrity,\n }\n}\n"]}
1
+ {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,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,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;0BAGS;IACtB,OAAO,EAAE;QACP,SAAS,EAAE;YACT,WAAW,EACT,sDAAsD;SACzD;KACF;CACF,CAAC,CAAA;AAcJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,CAAC,EAAE;QACT,MAAM,KAAK,GAAG;YACZ,eAAe,CAAC,CAAC,EAAE,EAAE;YACrB,YAAY,CAAC,CAAC,QAAQ,EAAE;YACxB,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ;YAC5B,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,oBAAoB,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;YACzC,qBAAqB,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE;SACnD,CAAA;QACD,IAAI,CAAC,CAAC,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,M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AAQ,EAAE,CAAC;QACd,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,UAAU;KACjB,CAAC,CAAA;IAEF,OAAO;QACL,EAAE,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;QACxB,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,KAAK;QACL,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,YAAY;QACZ,MAAM;QACN,SAAS;KACV,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport assert from 'node:assert'\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 prettyBytes from 'pretty-bytes'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pack',\n usage: '',\n description: `Create a tarball from a package in the current directory or specified folder.\n \n The tarball will be saved to the current directory with the name\n <name>-<version>.tgz.`,\n options: {\n 'dry-run': {\n description:\n 'Show what would be packed without creating a tarball',\n },\n },\n })\n\ntype CommandResult = {\n id: string\n name: string\n version: string\n filename: string\n files: string[]\n size: number\n unpackedSize: number\n shasum?: string\n integrity?: string\n}\n\nexport const views = {\n human: r => {\n const lines = [\n `📦 Package: ${r.id}`,\n `📄 File: ${r.filename}`,\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 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 const isDryRun = conf.options['dry-run']\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: 'prepack',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepare',\n })\n\n const {\n name,\n version,\n filename,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n } = await packTarball(manifest, manifestDir, conf)\n\n if (!isDryRun) {\n await writeFile(join(manifestDir, filename), tarballData)\n }\n\n await run({\n ...runOptions,\n arg0: 'postpack',\n })\n\n return {\n id: `${name}@${version}`,\n name,\n version,\n filename,\n files,\n size: tarballData.length,\n unpackedSize,\n shasum,\n integrity,\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ1D,eAAO,MAAM,KAAK,EAAE,YAsBhB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,KAAK;;;CAkBuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAuJ5C,CAAA"}
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/publish.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ1D,eAAO,MAAM,KAAK,EAAE,YAsBhB,CAAA;AAEJ,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,KAAK;;;CAiBuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAyJ5C,CAAA"}
@@ -32,19 +32,18 @@ export const usage = () => commandUsage({
32
32
  export const views = {
33
33
  human: r => {
34
34
  const lines = [
35
- `✅ Published ${r.name}@${r.version}`,
36
35
  `📦 Package: ${r.id}`,
37
36
  `🏷️ Tag: ${r.tag}`,
38
37
  `📡 Registry: ${r.registry}`,
39
- `📁 ${r.files.length} files`,
38
+ `📁 ${r.files.length} Files`,
40
39
  ...r.files.map(f => ` - ${f}`),
41
- `📊 package size: ${prettyBytes(r.size)}`,
42
- `📂 unpacked size: ${prettyBytes(r.unpackedSize)}`,
40
+ `📊 Package Size: ${prettyBytes(r.size)}`,
41
+ `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,
43
42
  ];
44
43
  if (r.shasum)
45
- lines.push(`🔒 shasum: ${r.shasum}`);
44
+ lines.push(`🔒 Shasum: ${r.shasum}`);
46
45
  if (r.integrity)
47
- lines.push(`🔐 integrity: ${r.integrity}`);
46
+ lines.push(`🔐 Integrity: ${r.integrity}`);
48
47
  return lines.join('\n');
49
48
  },
50
49
  json: r => r,
@@ -81,7 +80,7 @@ export const command = async (conf) => {
81
80
  ...runOptions,
82
81
  arg0: 'prepare',
83
82
  });
84
- const { name, version, filename, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(manifest, manifestDir, conf);
83
+ const { name, version, tarballName, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(manifest, manifestDir, conf);
85
84
  await run({
86
85
  ...runOptions,
87
86
  arg0: 'postpack',
@@ -106,13 +105,14 @@ export const command = async (conf) => {
106
105
  ...manifest.dist,
107
106
  integrity,
108
107
  shasum,
109
- tarball: new URL(`${name}/-/${filename}`, registryUrl).href,
108
+ tarball: new URL(`${name}/-/${tarballName}`, registryUrl)
109
+ .href,
110
110
  },
111
111
  },
112
112
  },
113
113
  access,
114
114
  _attachments: {
115
- [filename]: {
115
+ [tarballName]: {
116
116
  content_type: 'application/octet-stream',
117
117
  data: tarballData.toString('base64'),
118
118
  length: tarballData.length,
@@ -143,6 +143,7 @@ export const command = async (conf) => {
143
143
  }
144
144
  if (response.statusCode !== 200 && response.statusCode !== 201) {
145
145
  throw error('Failed to publish package', {
146
+ url: publishUrl,
146
147
  response,
147
148
  });
148
149
  }
@@ -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,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,M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AY;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 `✅ Published ${r.name}@${r.version}`,\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 filename,\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}/-/${filename}`, registryUrl).href,\n },\n },\n },\n access,\n _attachments: {\n [filename]: {\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 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,MAAM,WAAW,CAAA;AACnC,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,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,WAAW,EAAE,kDAAkD;YAC/D,KAAK,EAAE,OAAO;SACf;KACF;CACF,CAAC,CAAA;AAgBJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,CAAC,EAAE;QACT,MAAM,KAAK,GAAG;YACZ,eAAe,CAAC,CAAC,EAAE,EAAE;YACrB,YAAY,CAAC,CAAC,GAAG,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AAU,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 } 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"]}
@@ -324,8 +324,13 @@ export declare const definition: import("jackspeak").Jack<{
324
324
  otp: {
325
325
  description: string;
326
326
  };
327
+ 'publish-directory': {
328
+ hint: string;
329
+ description: string;
330
+ };
327
331
  } & {
328
332
  otp: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
333
+ 'publish-directory': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
329
334
  } & {
330
335
  yes: {
331
336
  short: string;
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAElE,eAAO,MAAM,aAAa,cAKjB,CAAA;AA6CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;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AM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA4MP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
@@ -550,6 +550,12 @@ export const definition = j
550
550
  otp: {
551
551
  description: `Provide an OTP to use when publishing a package.`,
552
552
  },
553
+ 'publish-directory': {
554
+ hint: 'path',
555
+ description: `Directory to use for pack and publish operations instead of the current directory.
556
+ Similar to pnpm's publishConfig.directory feature.
557
+ The directory must exist and nothing will be copied to it.`,
558
+ },
553
559
  })
554
560
  .flag({
555
561
  yes: {
@@ -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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,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;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 = process.stdout.isTTY ? 'human' : '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 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 '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\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 ] 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 })\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 })\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,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;AAElE,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,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,YAAY;I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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 = process.stdout.isTTY ? 'human' : '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 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 '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\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 ] 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 })\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"]}
@@ -4,6 +4,7 @@ export type PackTarballResult = {
4
4
  name: string;
5
5
  version: string;
6
6
  filename: string;
7
+ tarballName: string;
7
8
  tarballData: Buffer;
8
9
  unpackedSize: number;
9
10
  files: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"pack-tarball.d.ts","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAO7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAuHD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,OACb,MAAM,UACH,YAAY,KACnB,OAAO,CAAC,iBAAiB,CAwL3B,CAAA"}
1
+ {"version":3,"file":"pack-tarball.d.ts","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAQ7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAuHD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,OACb,MAAM,UACH,YAAY,KACnB,OAAO,CAAC,iBAAiB,CAsN3B,CAAA"}
@@ -3,7 +3,9 @@ import { minimatch } from 'minimatch';
3
3
  import { error } from '@vltpkg/error-cause';
4
4
  import * as ssri from 'ssri';
5
5
  import assert from 'node:assert';
6
+ import { existsSync, statSync } from 'node:fs';
6
7
  import { Spec } from '@vltpkg/spec';
8
+ import { join } from 'node:path';
7
9
  /**
8
10
  * Replace workspace: and catalog: specs with actual versions
9
11
  * @param {Manifest} manifest_ - The manifest to process
@@ -86,13 +88,31 @@ const replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
86
88
  * @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)
87
89
  */
88
90
  export const packTarball = async (manifest, dir, config) => {
91
+ let packDir = dir;
92
+ // Check if publishDirectory is configured
93
+ const publishDirectory = config.get('publish-directory');
94
+ if (publishDirectory) {
95
+ // Validate that the publish directory exists and is a directory
96
+ assert(existsSync(publishDirectory), error(`Publish directory does not exist: ${publishDirectory}`, {
97
+ found: publishDirectory,
98
+ }));
99
+ assert(statSync(publishDirectory).isDirectory(), error(`Publish directory is not a directory: ${publishDirectory}`, {
100
+ found: publishDirectory,
101
+ wanted: 'directory',
102
+ }));
103
+ if (existsSync(join(publishDirectory, 'package.json'))) {
104
+ manifest = config.options.packageJson.read(publishDirectory);
105
+ }
106
+ packDir = publishDirectory;
107
+ }
89
108
  assert(manifest.name && manifest.version, error('Package must have a name and version'));
90
109
  const processedManifest = replaceWorkspaceAndCatalogSpecs(manifest, config);
91
110
  const filename = `${manifest.name.replace('@', '').replace('/', '-')}-${manifest.version}.tgz`;
111
+ const tarballName = `${manifest.name}-${manifest.version}.tgz`;
92
112
  try {
93
- config.options.packageJson.write(dir, processedManifest);
113
+ config.options.packageJson.write(packDir, processedManifest);
94
114
  const tarballData = await tarCreate({
95
- cwd: dir,
115
+ cwd: packDir,
96
116
  gzip: true,
97
117
  portable: true,
98
118
  prefix: 'package/',
@@ -211,6 +231,7 @@ export const packTarball = async (manifest, dir, config) => {
211
231
  name: manifest.name,
212
232
  version: manifest.version,
213
233
  filename,
234
+ tarballName,
214
235
  tarballData,
215
236
  unpackedSize,
216
237
  files,
@@ -219,8 +240,8 @@ export const packTarball = async (manifest, dir, config) => {
219
240
  };
220
241
  }
221
242
  finally {
222
- // Restore the original package.json
223
- config.options.packageJson.write(dir, manifest);
243
+ // Restore the original package.json to the pack directory
244
+ config.options.packageJson.write(packDir, manifest);
224
245
  }
225
246
  };
226
247
  //# sourceMappingURL=pack-tarball.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pack-tarball.js","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAcnC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,CACtC,SAAmB,EACnB,MAAoB,EACV,EAAE;IACZ,qEAAqE;IACrE,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;IAE3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B,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC,CAAA;YACF,MAAM;iBACH,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;iBAC1B,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;iBACnB,KAAK,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,CAAC,GAAG,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;QAEF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;YAC9C,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;SAC7C,CAAC,CAAA;QAEF,gEAAgE;QAChE,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAA;QACtD,0DAA0D;QAC1D,6DAA6D;QAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAEnC,CAAA;QAEb,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,QAAQ;YACR,WAAW;YACX,YAAY;YACZ,KAAK;YACL,SAAS;YACT,MAAM;SACP,CAAA;IACH,CAAC;YAAS,CAAC;QACT,oCAAoC;QACpC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACjD,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { Manifest } from '@vltpkg/types'\nimport { create as tarCreate, list as tarList } from 'tar'\nimport { minimatch } from 'minimatch'\nimport { error } from '@vltpkg/error-cause'\nimport * as ssri from 'ssri'\nimport assert from 'node:assert'\nimport { Spec } from '@vltpkg/spec'\nimport type { LoadedConfig } from './config/index.ts'\n\nexport type PackTarballResult = {\n name: string\n version: string\n filename: string\n tarballData: Buffer\n unpackedSize: number\n files: string[]\n integrity?: string\n shasum?: string\n}\n\n/**\n * Replace workspace: and catalog: specs with actual versions\n * @param {Manifest} manifest_ - The manifest to process\n * @param {LoadedConfig} config - The loaded configuration containing project root, monorepo, and catalog data\n * @returns {Manifest} The manifest with replaced specs\n */\nconst replaceWorkspaceAndCatalogSpecs = (\n manifest_: Manifest,\n config: LoadedConfig,\n): Manifest => {\n // Create a deep copy of the manifest to avoid modifying the original\n const manifest = structuredClone(manifest_)\n\n // Get workspace and catalog configuration from config\n const { monorepo, catalog = {}, catalogs = {} } = config.options\n\n // Process dependency types\n const depTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n 'peerDependencies',\n ] as const\n\n for (const depType of depTypes) {\n const deps = manifest[depType]\n /* c8 ignore next */\n if (!deps || typeof deps !== 'object') continue\n\n const depsObj = deps as Record<string, unknown>\n for (const [depName, depSpec] of Object.entries(depsObj)) {\n /* c8 ignore next */\n if (typeof depSpec !== 'string') continue\n\n const spec = Spec.parse(`${depName}@${depSpec}`, {\n catalog,\n catalogs,\n })\n\n switch (spec.type) {\n case 'workspace': {\n assert(\n monorepo,\n error(`No workspace configuration found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspaceName = spec.workspace\n assert(\n workspaceName,\n error(`No workspace name found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspace = monorepo.get(workspaceName)\n assert(\n workspace,\n error(`Workspace '${workspaceName}' not found`, {\n found: workspaceName,\n validOptions: Array.from(monorepo.keys()),\n }),\n )\n\n const actualVersion = workspace.manifest.version\n assert(\n actualVersion,\n error(\n `No version found for workspace '${workspaceName}'`,\n {\n found: workspaceName,\n wanted: 'package version',\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n\n case 'catalog': {\n const catalogName = spec.catalog || ''\n const targetCatalog =\n catalogName ? catalogs[catalogName] : catalog\n assert(\n targetCatalog,\n error(`Catalog '${catalogName}' not found`, {\n found: catalogName,\n validOptions: Object.keys(catalogs),\n }),\n )\n\n const actualVersion = targetCatalog[depName]\n assert(\n actualVersion,\n error(\n `Package '${depName}' not found in catalog '${catalogName || 'default'}'`,\n {\n found: depName,\n validOptions: Object.keys(targetCatalog),\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n }\n }\n }\n\n return manifest\n}\n\n/**\n * Create a tarball from a package directory\n * @param {Manifest} manifest - The manifest of the package to pack\n * @param {string} dir - The directory containing the package to pack\n * @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)\n * @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)\n */\nexport const packTarball = async (\n manifest: Manifest,\n dir: string,\n config: LoadedConfig,\n): Promise<PackTarballResult> => {\n assert(\n manifest.name && manifest.version,\n error('Package must have a name and version'),\n )\n\n const processedManifest = replaceWorkspaceAndCatalogSpecs(\n manifest,\n config,\n )\n\n const filename = `${manifest.name.replace('@', '').replace('/', '-')}-${manifest.version}.tgz`\n\n try {\n config.options.packageJson.write(dir, processedManifest)\n\n const tarballData = await tarCreate(\n {\n cwd: dir,\n gzip: true,\n portable: true,\n prefix: 'package/',\n filter: (path: string) => {\n // Normalize path - remove leading './'\n const normalizedPath = path.replace(/^\\.\\//, '')\n\n // Always include root directory\n if (path === '.' || normalizedPath === '') {\n return true\n }\n\n // Always exclude certain files/directories\n const alwaysExcludePatterns = [\n /^\\.?\\/?\\.git(\\/|$)/,\n /^\\.?\\/?node_modules(\\/|$)/,\n /^\\.?\\/?\\.nyc_output(\\/|$)/,\n /^\\.?\\/?coverage(\\/|$)/,\n /^\\.?\\/?\\.DS_Store$/,\n /^\\.?\\/?\\.npmrc$/,\n /^\\.?\\/?package-lock\\.json$/,\n /^\\.?\\/?yarn\\.lock$/,\n /^\\.?\\/?pnpm-lock\\.yaml$/,\n /^\\.?\\/?bun\\.lockb$/,\n /^\\.?\\/?bun\\.lock$/,\n /^\\.?\\/?vlt-lock\\.json$/,\n /~$/,\n /\\.swp$/,\n ]\n\n if (\n alwaysExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return false\n }\n\n // Always include certain files\n const alwaysIncludePatterns = [\n /^README(\\..*)?$/i,\n /^CHANGELOG(\\..*)?$/i,\n /^HISTORY(\\..*)?$/i,\n /^LICENSE(\\..*)?$/i,\n /^LICENCE(\\..*)?$/i,\n ]\n\n if (\n alwaysIncludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return true\n }\n\n // Always include package.json\n if (normalizedPath === 'package.json') {\n return true\n }\n\n // If files field is specified in package.json, use it for inclusion\n const manifestWithFiles = manifest as Manifest & {\n files?: string[]\n }\n if (\n manifestWithFiles.files &&\n Array.isArray(manifestWithFiles.files)\n ) {\n // Empty files array means exclude everything except always-included files\n if (manifestWithFiles.files.length === 0) {\n return false\n }\n return manifestWithFiles.files.some((pattern: string) => {\n if (pattern.endsWith('/')) {\n const dirName = pattern.slice(0, -1)\n const globPattern = pattern.replace(/\\/$/, '/**')\n const matchesDir = normalizedPath === dirName\n const matchesContents = minimatch(\n normalizedPath,\n globPattern,\n {\n dot: true,\n },\n )\n return matchesDir || matchesContents\n }\n\n // File pattern: check direct match and if this path is a directory that could contain the pattern\n const directMatch = minimatch(normalizedPath, pattern, {\n dot: true,\n })\n // Check if this path is a directory that could contain the pattern\n const isParentDir =\n pattern.includes('/') &&\n pattern.startsWith(normalizedPath + '/')\n return directMatch || isParentDir\n })\n }\n\n // Default behavior when no files field - exclude common development files\n const defaultExcludePatterns = [\n /^\\.?\\/?\\.vscode(\\/|$)/,\n /^\\.?\\/?\\.idea(\\/|$)/,\n /^\\.?\\/?\\.gitignore$/,\n /^\\.?\\/?\\.npmignore$/,\n /^\\.?\\/?\\.editorconfig$/,\n ]\n\n return !defaultExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n },\n },\n ['.'],\n ).concat()\n\n let unpackedSize = 0\n const files: string[] = []\n await new Promise<void>((resolve, reject) => {\n const stream = tarList({\n onentry: entry => {\n if (entry.type === 'File') {\n unpackedSize += entry.size\n // Remove the package/ prefix for cleaner file listing\n const cleanPath = entry.path.replace(/^[^/]+\\//, '')\n if (cleanPath) {\n // Skip empty paths\n files.push(cleanPath)\n }\n }\n },\n })\n stream\n .on('end', () => resolve())\n .on('error', reject)\n .write(tarballData)\n stream.end()\n })\n\n const integrityMap = ssri.fromData(tarballData, {\n algorithms: [...new Set(['sha1', 'sha512'])],\n })\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const integrity = integrityMap.sha512?.[0]?.toString()\n // @ts-expect-error -- types from DT are missing hexDigest\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n const shasum = integrityMap.sha1?.[0]?.hexDigest() as\n | string\n | undefined\n\n return {\n name: manifest.name,\n version: manifest.version,\n filename,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n }\n } finally {\n // Restore the original package.json\n config.options.packageJson.write(dir, manifest)\n }\n}\n"]}
1
+ {"version":3,"file":"pack-tarball.js","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAchC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,CACtC,SAAmB,EACnB,MAAoB,EACV,EAAE;IACZ,qEAAqE;IACrE,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;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C;SAC7C,CAAC,CAAA;QAEF,gEAAgE;QAChE,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAA;QACtD,0DAA0D;QAC1D,6DAA6D;QAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAEnC,CAAA;QAEb,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,QAAQ;YACR,WAAW;YACX,WAAW;YACX,YAAY;YACZ,KAAK;YACL,SAAS;YACT,MAAM;SACP,CAAA;IACH,CAAC;YAAS,CAAC;QACT,0DAA0D;QAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { Manifest } from '@vltpkg/types'\nimport { create as tarCreate, list as tarList } from 'tar'\nimport { minimatch } from 'minimatch'\nimport { error } from '@vltpkg/error-cause'\nimport * as ssri from 'ssri'\nimport assert from 'node:assert'\nimport { existsSync, statSync } from 'node:fs'\nimport { Spec } from '@vltpkg/spec'\nimport type { LoadedConfig } from './config/index.ts'\nimport { join } from 'node:path'\n\nexport type PackTarballResult = {\n name: string\n version: string\n filename: string\n tarballName: string\n tarballData: Buffer\n unpackedSize: number\n files: string[]\n integrity?: string\n shasum?: string\n}\n\n/**\n * Replace workspace: and catalog: specs with actual versions\n * @param {Manifest} manifest_ - The manifest to process\n * @param {LoadedConfig} config - The loaded configuration containing project root, monorepo, and catalog data\n * @returns {Manifest} The manifest with replaced specs\n */\nconst replaceWorkspaceAndCatalogSpecs = (\n manifest_: Manifest,\n config: LoadedConfig,\n): Manifest => {\n // Create a deep copy of the manifest to avoid modifying the original\n const manifest = structuredClone(manifest_)\n\n // Get workspace and catalog configuration from config\n const { monorepo, catalog = {}, catalogs = {} } = config.options\n\n // Process dependency types\n const depTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n 'peerDependencies',\n ] as const\n\n for (const depType of depTypes) {\n const deps = manifest[depType]\n /* c8 ignore next */\n if (!deps || typeof deps !== 'object') continue\n\n const depsObj = deps as Record<string, unknown>\n for (const [depName, depSpec] of Object.entries(depsObj)) {\n /* c8 ignore next */\n if (typeof depSpec !== 'string') continue\n\n const spec = Spec.parse(`${depName}@${depSpec}`, {\n catalog,\n catalogs,\n })\n\n switch (spec.type) {\n case 'workspace': {\n assert(\n monorepo,\n error(`No workspace configuration found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspaceName = spec.workspace\n assert(\n workspaceName,\n error(`No workspace name found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspace = monorepo.get(workspaceName)\n assert(\n workspace,\n error(`Workspace '${workspaceName}' not found`, {\n found: workspaceName,\n validOptions: Array.from(monorepo.keys()),\n }),\n )\n\n const actualVersion = workspace.manifest.version\n assert(\n actualVersion,\n error(\n `No version found for workspace '${workspaceName}'`,\n {\n found: workspaceName,\n wanted: 'package version',\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n\n case 'catalog': {\n const catalogName = spec.catalog || ''\n const targetCatalog =\n catalogName ? catalogs[catalogName] : catalog\n assert(\n targetCatalog,\n error(`Catalog '${catalogName}' not found`, {\n found: catalogName,\n validOptions: Object.keys(catalogs),\n }),\n )\n\n const actualVersion = targetCatalog[depName]\n assert(\n actualVersion,\n error(\n `Package '${depName}' not found in catalog '${catalogName || 'default'}'`,\n {\n found: depName,\n validOptions: Object.keys(targetCatalog),\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n }\n }\n }\n\n return manifest\n}\n\n/**\n * Create a tarball from a package directory\n * @param {Manifest} manifest - The manifest of the package to pack\n * @param {string} dir - The directory containing the package to pack\n * @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)\n * @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)\n */\nexport const packTarball = async (\n manifest: Manifest,\n dir: string,\n config: LoadedConfig,\n): Promise<PackTarballResult> => {\n let packDir = dir\n\n // Check if publishDirectory is configured\n const publishDirectory = config.get('publish-directory')\n if (publishDirectory) {\n // Validate that the publish directory exists and is a directory\n assert(\n existsSync(publishDirectory),\n error(`Publish directory does not exist: ${publishDirectory}`, {\n found: publishDirectory,\n }),\n )\n assert(\n statSync(publishDirectory).isDirectory(),\n error(\n `Publish directory is not a directory: ${publishDirectory}`,\n {\n found: publishDirectory,\n wanted: 'directory',\n },\n ),\n )\n if (existsSync(join(publishDirectory, 'package.json'))) {\n manifest = config.options.packageJson.read(publishDirectory)\n }\n packDir = publishDirectory\n }\n\n assert(\n manifest.name && manifest.version,\n error('Package must have a name and version'),\n )\n\n const processedManifest = replaceWorkspaceAndCatalogSpecs(\n manifest,\n config,\n )\n\n const filename = `${manifest.name.replace('@', '').replace('/', '-')}-${manifest.version}.tgz`\n const tarballName = `${manifest.name}-${manifest.version}.tgz`\n\n try {\n config.options.packageJson.write(packDir, processedManifest)\n\n const tarballData = await tarCreate(\n {\n cwd: packDir,\n gzip: true,\n portable: true,\n prefix: 'package/',\n filter: (path: string) => {\n // Normalize path - remove leading './'\n const normalizedPath = path.replace(/^\\.\\//, '')\n\n // Always include root directory\n if (path === '.' || normalizedPath === '') {\n return true\n }\n\n // Always exclude certain files/directories\n const alwaysExcludePatterns = [\n /^\\.?\\/?\\.git(\\/|$)/,\n /^\\.?\\/?node_modules(\\/|$)/,\n /^\\.?\\/?\\.nyc_output(\\/|$)/,\n /^\\.?\\/?coverage(\\/|$)/,\n /^\\.?\\/?\\.DS_Store$/,\n /^\\.?\\/?\\.npmrc$/,\n /^\\.?\\/?package-lock\\.json$/,\n /^\\.?\\/?yarn\\.lock$/,\n /^\\.?\\/?pnpm-lock\\.yaml$/,\n /^\\.?\\/?bun\\.lockb$/,\n /^\\.?\\/?bun\\.lock$/,\n /^\\.?\\/?vlt-lock\\.json$/,\n /~$/,\n /\\.swp$/,\n ]\n\n if (\n alwaysExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return false\n }\n\n // Always include certain files\n const alwaysIncludePatterns = [\n /^README(\\..*)?$/i,\n /^CHANGELOG(\\..*)?$/i,\n /^HISTORY(\\..*)?$/i,\n /^LICENSE(\\..*)?$/i,\n /^LICENCE(\\..*)?$/i,\n ]\n\n if (\n alwaysIncludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return true\n }\n\n // Always include package.json\n if (normalizedPath === 'package.json') {\n return true\n }\n\n // If files field is specified in package.json, use it for inclusion\n const manifestWithFiles = manifest as Manifest & {\n files?: string[]\n }\n if (\n manifestWithFiles.files &&\n Array.isArray(manifestWithFiles.files)\n ) {\n // Empty files array means exclude everything except always-included files\n if (manifestWithFiles.files.length === 0) {\n return false\n }\n return manifestWithFiles.files.some((pattern: string) => {\n if (pattern.endsWith('/')) {\n const dirName = pattern.slice(0, -1)\n const globPattern = pattern.replace(/\\/$/, '/**')\n const matchesDir = normalizedPath === dirName\n const matchesContents = minimatch(\n normalizedPath,\n globPattern,\n {\n dot: true,\n },\n )\n return matchesDir || matchesContents\n }\n\n // File pattern: check direct match and if this path is a directory that could contain the pattern\n const directMatch = minimatch(normalizedPath, pattern, {\n dot: true,\n })\n // Check if this path is a directory that could contain the pattern\n const isParentDir =\n pattern.includes('/') &&\n pattern.startsWith(normalizedPath + '/')\n return directMatch || isParentDir\n })\n }\n\n // Default behavior when no files field - exclude common development files\n const defaultExcludePatterns = [\n /^\\.?\\/?\\.vscode(\\/|$)/,\n /^\\.?\\/?\\.idea(\\/|$)/,\n /^\\.?\\/?\\.gitignore$/,\n /^\\.?\\/?\\.npmignore$/,\n /^\\.?\\/?\\.editorconfig$/,\n ]\n\n return !defaultExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n },\n },\n ['.'],\n ).concat()\n\n let unpackedSize = 0\n const files: string[] = []\n await new Promise<void>((resolve, reject) => {\n const stream = tarList({\n onentry: entry => {\n if (entry.type === 'File') {\n unpackedSize += entry.size\n // Remove the package/ prefix for cleaner file listing\n const cleanPath = entry.path.replace(/^[^/]+\\//, '')\n if (cleanPath) {\n // Skip empty paths\n files.push(cleanPath)\n }\n }\n },\n })\n stream\n .on('end', () => resolve())\n .on('error', reject)\n .write(tarballData)\n stream.end()\n })\n\n const integrityMap = ssri.fromData(tarballData, {\n algorithms: [...new Set(['sha1', 'sha512'])],\n })\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const integrity = integrityMap.sha512?.[0]?.toString()\n // @ts-expect-error -- types from DT are missing hexDigest\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n const shasum = integrityMap.sha1?.[0]?.hexDigest() as\n | string\n | undefined\n\n return {\n name: manifest.name,\n version: manifest.version,\n filename,\n tarballName,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n }\n } finally {\n // Restore the original package.json to the pack directory\n config.options.packageJson.write(packDir, manifest)\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": "0.0.0-17",
4
+ "version": "0.0.0-18",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -37,28 +37,28 @@
37
37
  "ssri": "^12.0.0",
38
38
  "supports-color": "^10.0.0",
39
39
  "tar": "^7.4.3",
40
- "@vltpkg/dep-id": "0.0.0-17",
41
- "@vltpkg/dot-prop": "0.0.0-17",
42
- "@vltpkg/git": "0.0.0-17",
43
- "@vltpkg/graph": "0.0.0-17",
44
- "@vltpkg/error-cause": "0.0.0-17",
45
- "@vltpkg/package-info": "0.0.0-17",
46
- "@vltpkg/output": "0.0.0-17",
47
- "@vltpkg/package-json": "0.0.0-17",
48
- "@vltpkg/registry-client": "0.0.0-17",
49
- "@vltpkg/query": "0.0.0-17",
50
- "@vltpkg/rollback-remove": "0.0.0-17",
51
- "@vltpkg/init": "0.0.0-17",
52
- "@vltpkg/run": "0.0.0-17",
53
- "@vltpkg/security-archive": "0.0.0-17",
54
- "@vltpkg/server": "0.0.0-17",
55
- "@vltpkg/spec": "0.0.0-17",
56
- "@vltpkg/types": "0.0.0-17",
57
- "@vltpkg/url-open": "0.0.0-17",
58
- "@vltpkg/workspaces": "0.0.0-17",
59
- "@vltpkg/xdg": "0.0.0-17",
60
- "@vltpkg/vlt-json": "0.0.0-17",
61
- "@vltpkg/vlx": "0.0.0-17"
40
+ "@vltpkg/error-cause": "0.0.0-18",
41
+ "@vltpkg/git": "0.0.0-18",
42
+ "@vltpkg/dot-prop": "0.0.0-18",
43
+ "@vltpkg/graph": "0.0.0-18",
44
+ "@vltpkg/package-info": "0.0.0-18",
45
+ "@vltpkg/init": "0.0.0-18",
46
+ "@vltpkg/package-json": "0.0.0-18",
47
+ "@vltpkg/dep-id": "0.0.0-18",
48
+ "@vltpkg/output": "0.0.0-18",
49
+ "@vltpkg/query": "0.0.0-18",
50
+ "@vltpkg/registry-client": "0.0.0-18",
51
+ "@vltpkg/rollback-remove": "0.0.0-18",
52
+ "@vltpkg/run": "0.0.0-18",
53
+ "@vltpkg/security-archive": "0.0.0-18",
54
+ "@vltpkg/server": "0.0.0-18",
55
+ "@vltpkg/types": "0.0.0-18",
56
+ "@vltpkg/spec": "0.0.0-18",
57
+ "@vltpkg/url-open": "0.0.0-18",
58
+ "@vltpkg/vlx": "0.0.0-18",
59
+ "@vltpkg/vlt-json": "0.0.0-18",
60
+ "@vltpkg/xdg": "0.0.0-18",
61
+ "@vltpkg/workspaces": "0.0.0-18"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@eslint/js": "^9.28.0",