@open-mercato/cli 0.11.1-develop.8512.1.2a0fb15d03 → 0.11.1-develop.8515.1.881743bf13
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/.turbo/turbo-build.log +1 -1
- package/dist/agentic/guides/module-facts.json +162 -162
- package/dist/agentic/guides/module-facts.v2.json +162 -162
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/manifest.json +1 -1
- package/dist/lib/module-inspection.js +19 -3
- package/dist/lib/module-inspection.js.map +2 -2
- package/package.json +7 -7
- package/src/lib/__tests__/module-inspection.test.ts +72 -0
- package/src/lib/module-inspection.ts +23 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# staff — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/staff
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# storage_s3 — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/storage-s3 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/storage-s3 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/storage-s3/src/modules/storage_s3
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# sync_akeneo — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/sync-akeneo 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/sync-akeneo 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/sync-akeneo/src/modules/sync_akeneo
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# sync_excel — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/sync_excel
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# system_status_overlays — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/enterprise 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/enterprise 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/enterprise/src/modules/system_status_overlays
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# telemetry — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/telemetry 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/telemetry 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/telemetry/src/modules/telemetry
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# tillio — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/tillio 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/tillio 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/tillio/src/modules/tillio
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# translations — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/translations
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# warranty_claims — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/warranty_claims
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# webhooks — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/webhooks 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/webhooks 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/webhooks/src/modules/webhooks
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# wms — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/wms
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# workflows — module facts (generated, do not edit)
|
|
2
|
-
<!-- generated from @open-mercato/core 0.11.1-develop.
|
|
2
|
+
<!-- generated from @open-mercato/core 0.11.1-develop.8515.1.881743bf13; core 0.11.1-develop.8515.1.881743bf13 — R1 staleness stamp -->
|
|
3
3
|
Source root: node_modules/@open-mercato/core/src/modules/workflows
|
|
4
4
|
|
|
5
5
|
## Sections
|
|
@@ -1185,7 +1185,7 @@
|
|
|
1185
1185
|
"facts": {
|
|
1186
1186
|
"title": "Example Module",
|
|
1187
1187
|
"description": "Demonstrates pages, APIs, entities and DI.",
|
|
1188
|
-
"coreVersion": "0.11.1-develop.
|
|
1188
|
+
"coreVersion": "0.11.1-develop.8515.1.881743bf13",
|
|
1189
1189
|
"sourcePackage": null,
|
|
1190
1190
|
"sourceVersion": null,
|
|
1191
1191
|
"sourceRoot": "src/modules/example",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
|
-
"generator": "@open-mercato/cli@0.11.1-develop.
|
|
3
|
+
"generator": "@open-mercato/cli@0.11.1-develop.8515.1.881743bf13",
|
|
4
4
|
"files": {
|
|
5
5
|
"AGENTS.md": "35c948a32e06ca64b4706970c55ec60946412b410938b22478233a2c5c43df56",
|
|
6
6
|
"BACKWARD_COMPATIBILITY.md": "aea1d1d36fcaf0446e7b4db7f07897f64f3e25e4ff61251170103c44d036173d"
|
|
@@ -47,6 +47,22 @@ function isModernYarnProject(appDir) {
|
|
|
47
47
|
directory = parent;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
const YARN_SETTING_UNREADABLE = "YARN_SETTING_UNREADABLE";
|
|
51
|
+
function yarnSettingError(message) {
|
|
52
|
+
return Object.assign(new Error(message), { code: YARN_SETTING_UNREADABLE });
|
|
53
|
+
}
|
|
54
|
+
function isYarnSettingError(error) {
|
|
55
|
+
return error instanceof Error && "code" in error && error.code === YARN_SETTING_UNREADABLE;
|
|
56
|
+
}
|
|
57
|
+
function parseYarnConfigValue(setting, stdout) {
|
|
58
|
+
const output = stdout.trim();
|
|
59
|
+
if (output === "" || output === "undefined") return void 0;
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(output);
|
|
62
|
+
} catch {
|
|
63
|
+
throw yarnSettingError(`Yarn setting ${setting} returned output that is not JSON.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
50
66
|
function yarnNpmConfiguration(appDir, packageName, temporaryDir) {
|
|
51
67
|
if (!isModernYarnProject(appDir)) return [];
|
|
52
68
|
const settings = /* @__PURE__ */ new Map();
|
|
@@ -57,8 +73,8 @@ function yarnNpmConfiguration(appDir, packageName, temporaryDir) {
|
|
|
57
73
|
stdio: ["ignore", "pipe", "pipe"],
|
|
58
74
|
timeout: 15e3
|
|
59
75
|
});
|
|
60
|
-
if (result.error || result.status !== 0) throw
|
|
61
|
-
settings.set(setting,
|
|
76
|
+
if (result.error || result.status !== 0) throw yarnSettingError(`Yarn setting ${setting} could not be read (exit ${result.status ?? "none"}).`);
|
|
77
|
+
settings.set(setting, parseYarnConfigValue(setting, result.stdout));
|
|
62
78
|
}
|
|
63
79
|
const scope = packageName.startsWith("@") ? packageName.slice(1).split("/")[0] : void 0;
|
|
64
80
|
const scopeSettings = scope ? record(record(settings.get("npmScopes"))[scope]) : {};
|
|
@@ -112,7 +128,7 @@ function inspectNpmModuleTarget(packageSpec, packageName, appDir, requiredModule
|
|
|
112
128
|
if (inspected.version !== packed.version) throw new Error("Packed artifact version disagrees with resolution");
|
|
113
129
|
return { packageName, packageSpec, ...inspected, locator: `npm:${packageName}` };
|
|
114
130
|
} catch (error) {
|
|
115
|
-
const safeDetail = isModulePackageExportError(error) && error instanceof Error ? ` ${error.message}` : "";
|
|
131
|
+
const safeDetail = (isModulePackageExportError(error) || isYarnSettingError(error)) && error instanceof Error ? ` ${error.message}` : "";
|
|
116
132
|
throw new Error(`Cannot inspect the exact module artifact for "${packageName}" while trying to ${inspectionStep}.${safeDetail} Check project registry credentials, package access and shipped src/dist module descriptors before retrying. No package was installed.`);
|
|
117
133
|
} finally {
|
|
118
134
|
fs.rmSync(temporaryDir, { recursive: true, force: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/module-inspection.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { execFileSync } from 'node:child_process'\nimport spawn from 'cross-spawn'\nimport { assertModulePackageExports, isModulePackageExportError } from './module-package'\n\nexport type InspectedModuleTarget = {\n packageName: string\n packageSpec: string\n moduleIds: string[]\n locator?: string\n version?: string\n}\n\ntype ArtifactInspection = { moduleIds: string[]; version?: string }\n\nfunction record(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {}\n}\n\nfunction inspectFiles(manifest: Record<string, unknown>, packageName: string, files: string[], requiredModuleIds: readonly string[], readSource: (relativePath: string) => string): ArtifactInspection {\n if (manifest.name !== packageName) throw new Error(`Inspected package does not match \"${packageName}\". No package was installed.`)\n const moduleIds = [...new Set(files.flatMap((file) => {\n const match = /^src\\/modules\\/([a-z0-9]+(?:_[a-z0-9]+)*)\\/index\\.ts$/.exec(file)\n return match && files.includes(`dist/modules/${match[1]}/index.js`) ? [match[1]] : []\n }))]\n const checkedModuleIds = requiredModuleIds.length ? requiredModuleIds : moduleIds.length === 1 ? moduleIds : []\n for (const moduleId of checkedModuleIds) {\n if (!moduleIds.includes(moduleId)) throw new Error(`Package \"${packageName}\" is missing source or compiled descriptors for \"${moduleId}\". No package was installed.`)\n assertModulePackageExports(manifest, packageName, moduleId, files, readSource)\n }\n if (moduleIds.length === 0) throw new Error(`Package \"${packageName}\" is missing source or compiled module descriptors. Build the package before retrying. No package was installed.`)\n return { moduleIds, ...(typeof manifest.version === 'string' ? { version: manifest.version } : {}) }\n}\n\nfunction inspectArchive(archive: string, packageName: string, requiredModuleIds: readonly string[]): ArtifactInspection {\n const manifest = record(JSON.parse(execFileSync('tar', ['-xOf', archive, 'package/package.json'], { encoding: 'utf8', timeout: 15_000 })))\n const files = execFileSync('tar', ['-tf', archive], { encoding: 'utf8', timeout: 15_000, maxBuffer: 16 * 1024 * 1024 }).split('\\n').filter((file) => file.startsWith('package/')).map((file) => file.slice('package/'.length))\n return inspectFiles(manifest, packageName, files, requiredModuleIds, (relativePath) => execFileSync('tar', ['-xOf', archive, `package/${relativePath}`], { encoding: 'utf8', timeout: 15_000, maxBuffer: 1024 * 1024 }))\n}\n\nfunction packageFiles(packageRoot: string, relativeDir = ''): string[] {\n return fs.readdirSync(path.join(packageRoot, relativeDir), { withFileTypes: true }).flatMap((entry) => {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) return []\n const relativePath = path.posix.join(relativeDir, entry.name)\n return entry.isDirectory() ? packageFiles(packageRoot, relativePath) : entry.isFile() ? [relativePath] : []\n })\n}\n\nfunction isModernYarnProject(appDir: string): boolean {\n let directory = appDir\n while (true) {\n if (fs.existsSync(path.join(directory, '.yarnrc.yml'))) return true\n const manifestPath = path.join(directory, 'package.json')\n if (fs.existsSync(manifestPath)) {\n const manifest = record(JSON.parse(fs.readFileSync(manifestPath, 'utf8')))\n if (typeof manifest.packageManager === 'string' && /^yarn@(?:[2-9]|[1-9][0-9]+)\\./.test(manifest.packageManager)) return true\n }\n const parent = path.dirname(directory)\n if (parent === directory) return false\n directory = parent\n }\n}\n\nfunction yarnNpmConfiguration(appDir: string, packageName: string, temporaryDir: string): string[] {\n if (!isModernYarnProject(appDir)) return []\n const settings = new Map<string, unknown>()\n for (const setting of ['npmRegistryServer', 'npmScopes', 'npmRegistries', 'npmAuthToken', 'npmAuthIdent']) {\n const result = spawn.sync(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', ['config', 'get', setting, '--json', '--no-redacted'], {\n cwd: appDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 15_000,\n })\n if (result.error || result.status !== 0) throw new Error('Cannot inspect project package registry configuration')\n settings.set(setting, JSON.parse(result.stdout))\n }\n const scope = packageName.startsWith('@') ? packageName.slice(1).split('/')[0] : undefined\n const scopeSettings = scope ? record(record(settings.get('npmScopes'))[scope]) : {}\n const registry = typeof scopeSettings.npmRegistryServer === 'string' ? scopeSettings.npmRegistryServer : settings.get('npmRegistryServer')\n if (typeof registry !== 'string') throw new Error('Missing project package registry')\n const registryUrl = new URL(registry)\n if (!['http:', 'https:'].includes(registryUrl.protocol) || registryUrl.username || registryUrl.password) throw new Error('Invalid project package registry')\n const registryKey = `//${registryUrl.host}${registryUrl.pathname}`.replace(/\\/$/, '')\n const registries = record(settings.get('npmRegistries'))\n const registrySettings = record(registries[registry.replace(/\\/$/, '')] ?? registries[registryKey] ?? registries[`${registryKey}/`])\n const auth = scopeSettings.npmAuthToken || scopeSettings.npmAuthIdent ? scopeSettings\n : registrySettings.npmAuthToken || registrySettings.npmAuthIdent ? registrySettings\n : { npmAuthToken: settings.get('npmAuthToken'), npmAuthIdent: settings.get('npmAuthIdent') }\n const userConfig = process.env.NPM_CONFIG_USERCONFIG ?? process.env.npm_config_userconfig ?? path.join(os.homedir(), '.npmrc')\n const existingConfig = fs.existsSync(userConfig) ? fs.readFileSync(userConfig, 'utf8') : ''\n const lines = [existingConfig, `registry=${JSON.stringify(registry)}`]\n if (scope) lines.push(`@${scope}:registry=${JSON.stringify(registry)}`)\n if (typeof auth.npmAuthToken === 'string' && auth.npmAuthToken) lines.push(`${registryKey}/:_authToken=${JSON.stringify(auth.npmAuthToken)}`)\n else if (typeof auth.npmAuthIdent === 'string' && auth.npmAuthIdent) lines.push(`${registryKey}/:_auth=${Buffer.from(auth.npmAuthIdent).toString('base64')}`)\n const configPath = path.join(temporaryDir, 'inspection.npmrc')\n fs.writeFileSync(configPath, `${lines.join('\\n')}\\n`, { mode: 0o600 })\n return ['--userconfig', configPath, '--registry', registry, ...(scope ? [`--@${scope}:registry=${registry}`] : [])]\n}\n\nexport function inspectNpmModuleTarget(packageSpec: string, packageName: string, appDir: string, requiredModuleIds: readonly string[] = []): InspectedModuleTarget {\n const filePrefix = `${packageName}@file:`\n if (packageSpec.startsWith(filePrefix)) {\n const packageRoot = path.resolve(appDir, packageSpec.slice(filePrefix.length))\n if (fs.statSync(packageRoot).isFile()) return { packageName, packageSpec, ...inspectArchive(packageRoot, packageName, requiredModuleIds) }\n const manifest = record(JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')))\n const inspected = inspectFiles(manifest, packageName, packageFiles(packageRoot), requiredModuleIds, (relativePath) => fs.readFileSync(path.join(packageRoot, relativePath), 'utf8'))\n return { packageName, packageSpec, ...inspected }\n }\n\n const temporaryDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-module-inspection-'))\n let inspectionStep = 'read the project registry configuration'\n try {\n const configurationArgs = yarnNpmConfiguration(appDir, packageName, temporaryDir)\n inspectionStep = 'fetch the exact npm artifact'\n const packedProcess = spawn.sync(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['pack', packageSpec, '--ignore-scripts', '--json', '--pack-destination', temporaryDir, ...configurationArgs], {\n cwd: appDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 60_000, maxBuffer: 16 * 1024 * 1024,\n })\n if (packedProcess.error || packedProcess.status !== 0) throw new Error('Artifact inspection failed')\n inspectionStep = 'parse the npm artifact response'\n const packages: unknown = JSON.parse(packedProcess.stdout)\n const packed = record(Array.isArray(packages) ? packages[0] : undefined)\n if (packed.name !== packageName || typeof packed.version !== 'string' || !/^[0-9A-Za-z.+-]+$/.test(packed.version)\n || typeof packed.filename !== 'string' || path.basename(packed.filename) !== packed.filename) throw new Error('Invalid packed manifest')\n inspectionStep = 'validate the packed module artifact'\n const inspected = inspectArchive(path.join(temporaryDir, packed.filename), packageName, requiredModuleIds)\n if (inspected.version !== packed.version) throw new Error('Packed artifact version disagrees with resolution')\n return { packageName, packageSpec, ...inspected, locator: `npm:${packageName}` }\n } catch (error) {\n const safeDetail = isModulePackageExportError(error) && error instanceof Error ? ` ${error.message}` : ''\n throw new Error(`Cannot inspect the exact module artifact for \"${packageName}\" while trying to ${inspectionStep}.${safeDetail} Check project registry credentials, package access and shipped src/dist module descriptors before retrying. No package was installed.`)\n } finally {\n fs.rmSync(temporaryDir, { recursive: true, force: true })\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAClB,SAAS,4BAA4B,kCAAkC;AAYvE,SAAS,OAAO,OAAyC;AACvD,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAmC,CAAC;AACpH;AAEA,SAAS,aAAa,UAAmC,aAAqB,OAAiB,mBAAsC,YAAkE;AACrM,MAAI,SAAS,SAAS,YAAa,OAAM,IAAI,MAAM,qCAAqC,WAAW,8BAA8B;AACjI,QAAM,YAAY,CAAC,GAAG,IAAI,IAAI,MAAM,QAAQ,CAAC,SAAS;AACpD,UAAM,QAAQ,wDAAwD,KAAK,IAAI;AAC/E,WAAO,SAAS,MAAM,SAAS,gBAAgB,MAAM,CAAC,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;AAAA,EACtF,CAAC,CAAC,CAAC;AACH,QAAM,mB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M,eAAe,KAAK,MAAM,KAAK,aAAa,MAAM,IAAI;AAC5D,WAAO,MAAM,YAAY,IAAI,aAAa,aAAa,YAAY,IAAI,MAAM,OAAO,IAAI,CAAC,YAAY,IAAI,CAAC;AAAA,EAC5G,CAAC;AACH;AAEA,SAAS,oBAAoB,QAAyB;AACpD,MAAI,YAAY;AAChB,SAAO,MAAM;AACX,QAAI,GAAG,WAAW,KAAK,KAAK,WAAW,aAAa,CAAC,EAAG,QAAO;AAC/D,UAAM,eAAe,KAAK,KAAK,WAAW,cAAc;AACxD,QAAI,GAAG,WAAW,YAAY,GAAG;AAC/B,YAAM,WAAW,OAAO,KAAK,MAAM,GAAG,aAAa,cAAc,MAAM,CAAC,CAAC;AACzE,UAAI,OAAO,SAAS,mBAAmB,YAAY,gCAAgC,KAAK,SAAS,cAAc,EAAG,QAAO;AAAA,IAC3H;AACA,UAAM,SAAS,KAAK,QAAQ,SAAS;AACrC,QAAI,WAAW,UAAW,QAAO;AACjC,gBAAY;AAAA,EACd;AACF;AAEA,SAAS,qBAAqB,QAAgB,aAAqB,cAAgC;AACjG,MAAI,CAAC,oBAAoB,MAAM,EAAG,QAAO,CAAC;AAC1C,QAAM,WAAW,oBAAI,IAAqB;AAC1C,aAAW,WAAW,CAAC,qBAAqB,aAAa,iBAAiB,gBAAgB,cAAc,GAAG;AACzG,UAAM,SAAS,MAAM,KAAK,QAAQ,aAAa,UAAU,aAAa,QAAQ,CAAC,UAAU,OAAO,SAAS,UAAU,eAAe,GAAG;AAAA,MACnI,KAAK;AAAA,MAAQ,UAAU;AAAA,MAAQ,OAAO,CAAC,UAAU,QAAQ,MAAM;AAAA,MAAG,SAAS;AAAA,IAC7E,CAAC;AACD,QAAI,OAAO,SAAS,OAAO,WAAW,EAAG,OAAM,
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { execFileSync } from 'node:child_process'\nimport spawn from 'cross-spawn'\nimport { assertModulePackageExports, isModulePackageExportError } from './module-package'\n\nexport type InspectedModuleTarget = {\n packageName: string\n packageSpec: string\n moduleIds: string[]\n locator?: string\n version?: string\n}\n\ntype ArtifactInspection = { moduleIds: string[]; version?: string }\n\nfunction record(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {}\n}\n\nfunction inspectFiles(manifest: Record<string, unknown>, packageName: string, files: string[], requiredModuleIds: readonly string[], readSource: (relativePath: string) => string): ArtifactInspection {\n if (manifest.name !== packageName) throw new Error(`Inspected package does not match \"${packageName}\". No package was installed.`)\n const moduleIds = [...new Set(files.flatMap((file) => {\n const match = /^src\\/modules\\/([a-z0-9]+(?:_[a-z0-9]+)*)\\/index\\.ts$/.exec(file)\n return match && files.includes(`dist/modules/${match[1]}/index.js`) ? [match[1]] : []\n }))]\n const checkedModuleIds = requiredModuleIds.length ? requiredModuleIds : moduleIds.length === 1 ? moduleIds : []\n for (const moduleId of checkedModuleIds) {\n if (!moduleIds.includes(moduleId)) throw new Error(`Package \"${packageName}\" is missing source or compiled descriptors for \"${moduleId}\". No package was installed.`)\n assertModulePackageExports(manifest, packageName, moduleId, files, readSource)\n }\n if (moduleIds.length === 0) throw new Error(`Package \"${packageName}\" is missing source or compiled module descriptors. Build the package before retrying. No package was installed.`)\n return { moduleIds, ...(typeof manifest.version === 'string' ? { version: manifest.version } : {}) }\n}\n\nfunction inspectArchive(archive: string, packageName: string, requiredModuleIds: readonly string[]): ArtifactInspection {\n const manifest = record(JSON.parse(execFileSync('tar', ['-xOf', archive, 'package/package.json'], { encoding: 'utf8', timeout: 15_000 })))\n const files = execFileSync('tar', ['-tf', archive], { encoding: 'utf8', timeout: 15_000, maxBuffer: 16 * 1024 * 1024 }).split('\\n').filter((file) => file.startsWith('package/')).map((file) => file.slice('package/'.length))\n return inspectFiles(manifest, packageName, files, requiredModuleIds, (relativePath) => execFileSync('tar', ['-xOf', archive, `package/${relativePath}`], { encoding: 'utf8', timeout: 15_000, maxBuffer: 1024 * 1024 }))\n}\n\nfunction packageFiles(packageRoot: string, relativeDir = ''): string[] {\n return fs.readdirSync(path.join(packageRoot, relativeDir), { withFileTypes: true }).flatMap((entry) => {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) return []\n const relativePath = path.posix.join(relativeDir, entry.name)\n return entry.isDirectory() ? packageFiles(packageRoot, relativePath) : entry.isFile() ? [relativePath] : []\n })\n}\n\nfunction isModernYarnProject(appDir: string): boolean {\n let directory = appDir\n while (true) {\n if (fs.existsSync(path.join(directory, '.yarnrc.yml'))) return true\n const manifestPath = path.join(directory, 'package.json')\n if (fs.existsSync(manifestPath)) {\n const manifest = record(JSON.parse(fs.readFileSync(manifestPath, 'utf8')))\n if (typeof manifest.packageManager === 'string' && /^yarn@(?:[2-9]|[1-9][0-9]+)\\./.test(manifest.packageManager)) return true\n }\n const parent = path.dirname(directory)\n if (parent === directory) return false\n directory = parent\n }\n}\n\nconst YARN_SETTING_UNREADABLE = 'YARN_SETTING_UNREADABLE'\n\nfunction yarnSettingError(message: string): Error {\n return Object.assign(new Error(message), { code: YARN_SETTING_UNREADABLE })\n}\n\nfunction isYarnSettingError(error: unknown): error is Error {\n return error instanceof Error && 'code' in error && error.code === YARN_SETTING_UNREADABLE\n}\n\nfunction parseYarnConfigValue(setting: string, stdout: string): unknown {\n const output = stdout.trim()\n if (output === '' || output === 'undefined') return undefined\n try {\n return JSON.parse(output)\n } catch {\n throw yarnSettingError(`Yarn setting ${setting} returned output that is not JSON.`)\n }\n}\n\nfunction yarnNpmConfiguration(appDir: string, packageName: string, temporaryDir: string): string[] {\n if (!isModernYarnProject(appDir)) return []\n const settings = new Map<string, unknown>()\n for (const setting of ['npmRegistryServer', 'npmScopes', 'npmRegistries', 'npmAuthToken', 'npmAuthIdent']) {\n const result = spawn.sync(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', ['config', 'get', setting, '--json', '--no-redacted'], {\n cwd: appDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 15_000,\n })\n if (result.error || result.status !== 0) throw yarnSettingError(`Yarn setting ${setting} could not be read (exit ${result.status ?? 'none'}).`)\n settings.set(setting, parseYarnConfigValue(setting, result.stdout))\n }\n const scope = packageName.startsWith('@') ? packageName.slice(1).split('/')[0] : undefined\n const scopeSettings = scope ? record(record(settings.get('npmScopes'))[scope]) : {}\n const registry = typeof scopeSettings.npmRegistryServer === 'string' ? scopeSettings.npmRegistryServer : settings.get('npmRegistryServer')\n if (typeof registry !== 'string') throw new Error('Missing project package registry')\n const registryUrl = new URL(registry)\n if (!['http:', 'https:'].includes(registryUrl.protocol) || registryUrl.username || registryUrl.password) throw new Error('Invalid project package registry')\n const registryKey = `//${registryUrl.host}${registryUrl.pathname}`.replace(/\\/$/, '')\n const registries = record(settings.get('npmRegistries'))\n const registrySettings = record(registries[registry.replace(/\\/$/, '')] ?? registries[registryKey] ?? registries[`${registryKey}/`])\n const auth = scopeSettings.npmAuthToken || scopeSettings.npmAuthIdent ? scopeSettings\n : registrySettings.npmAuthToken || registrySettings.npmAuthIdent ? registrySettings\n : { npmAuthToken: settings.get('npmAuthToken'), npmAuthIdent: settings.get('npmAuthIdent') }\n const userConfig = process.env.NPM_CONFIG_USERCONFIG ?? process.env.npm_config_userconfig ?? path.join(os.homedir(), '.npmrc')\n const existingConfig = fs.existsSync(userConfig) ? fs.readFileSync(userConfig, 'utf8') : ''\n const lines = [existingConfig, `registry=${JSON.stringify(registry)}`]\n if (scope) lines.push(`@${scope}:registry=${JSON.stringify(registry)}`)\n if (typeof auth.npmAuthToken === 'string' && auth.npmAuthToken) lines.push(`${registryKey}/:_authToken=${JSON.stringify(auth.npmAuthToken)}`)\n else if (typeof auth.npmAuthIdent === 'string' && auth.npmAuthIdent) lines.push(`${registryKey}/:_auth=${Buffer.from(auth.npmAuthIdent).toString('base64')}`)\n const configPath = path.join(temporaryDir, 'inspection.npmrc')\n fs.writeFileSync(configPath, `${lines.join('\\n')}\\n`, { mode: 0o600 })\n return ['--userconfig', configPath, '--registry', registry, ...(scope ? [`--@${scope}:registry=${registry}`] : [])]\n}\n\nexport function inspectNpmModuleTarget(packageSpec: string, packageName: string, appDir: string, requiredModuleIds: readonly string[] = []): InspectedModuleTarget {\n const filePrefix = `${packageName}@file:`\n if (packageSpec.startsWith(filePrefix)) {\n const packageRoot = path.resolve(appDir, packageSpec.slice(filePrefix.length))\n if (fs.statSync(packageRoot).isFile()) return { packageName, packageSpec, ...inspectArchive(packageRoot, packageName, requiredModuleIds) }\n const manifest = record(JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')))\n const inspected = inspectFiles(manifest, packageName, packageFiles(packageRoot), requiredModuleIds, (relativePath) => fs.readFileSync(path.join(packageRoot, relativePath), 'utf8'))\n return { packageName, packageSpec, ...inspected }\n }\n\n const temporaryDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mercato-module-inspection-'))\n let inspectionStep = 'read the project registry configuration'\n try {\n const configurationArgs = yarnNpmConfiguration(appDir, packageName, temporaryDir)\n inspectionStep = 'fetch the exact npm artifact'\n const packedProcess = spawn.sync(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['pack', packageSpec, '--ignore-scripts', '--json', '--pack-destination', temporaryDir, ...configurationArgs], {\n cwd: appDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 60_000, maxBuffer: 16 * 1024 * 1024,\n })\n if (packedProcess.error || packedProcess.status !== 0) throw new Error('Artifact inspection failed')\n inspectionStep = 'parse the npm artifact response'\n const packages: unknown = JSON.parse(packedProcess.stdout)\n const packed = record(Array.isArray(packages) ? packages[0] : undefined)\n if (packed.name !== packageName || typeof packed.version !== 'string' || !/^[0-9A-Za-z.+-]+$/.test(packed.version)\n || typeof packed.filename !== 'string' || path.basename(packed.filename) !== packed.filename) throw new Error('Invalid packed manifest')\n inspectionStep = 'validate the packed module artifact'\n const inspected = inspectArchive(path.join(temporaryDir, packed.filename), packageName, requiredModuleIds)\n if (inspected.version !== packed.version) throw new Error('Packed artifact version disagrees with resolution')\n return { packageName, packageSpec, ...inspected, locator: `npm:${packageName}` }\n } catch (error) {\n const safeDetail = (isModulePackageExportError(error) || isYarnSettingError(error)) && error instanceof Error ? ` ${error.message}` : ''\n throw new Error(`Cannot inspect the exact module artifact for \"${packageName}\" while trying to ${inspectionStep}.${safeDetail} Check project registry credentials, package access and shipped src/dist module descriptors before retrying. No package was installed.`)\n } finally {\n fs.rmSync(temporaryDir, { recursive: true, force: true })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAClB,SAAS,4BAA4B,kCAAkC;AAYvE,SAAS,OAAO,OAAyC;AACvD,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAmC,CAAC;AACpH;AAEA,SAAS,aAAa,UAAmC,aAAqB,OAAiB,mBAAsC,YAAkE;AACrM,MAAI,SAAS,SAAS,YAAa,OAAM,IAAI,MAAM,qCAAqC,WAAW,8BAA8B;AACjI,QAAM,YAAY,CAAC,GAAG,IAAI,IAAI,MAAM,QAAQ,CAAC,SAAS;AACpD,UAAM,QAAQ,wDAAwD,KAAK,IAAI;AAC/E,WAAO,SAAS,MAAM,SAAS,gBAAgB,MAAM,CAAC,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;AAAA,EACtF,CAAC,CAAC,CAAC;AACH,QAAM,mBAAmB,kBAAkB,SAAS,oBAAoB,UAAU,WAAW,IAAI,YAAY,CAAC;AAC9G,aAAW,YAAY,kBAAkB;AACvC,QAAI,CAAC,UAAU,SAAS,QAAQ,EAAG,OAAM,IAAI,MAAM,YAAY,WAAW,oDAAoD,QAAQ,8BAA8B;AACpK,+BAA2B,UAAU,aAAa,UAAU,OAAO,UAAU;AAAA,EAC/E;AACA,MAAI,UAAU,WAAW,EAAG,OA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AAW,qBAAqB,cAAc,IAAI,UAAU,wIAAwI;AAAA,EACvQ,UAAE;AACA,OAAG,OAAO,cAAc,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,EAC1D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cli",
|
|
3
|
-
"version": "0.11.1-develop.
|
|
3
|
+
"version": "0.11.1-develop.8515.1.881743bf13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@mikro-orm/decorators": "^7.1.14",
|
|
61
61
|
"@mikro-orm/migrations": "^7.1.14",
|
|
62
62
|
"@mikro-orm/postgresql": "^7.1.14",
|
|
63
|
-
"@open-mercato/events": "0.11.1-develop.
|
|
64
|
-
"@open-mercato/queue": "0.11.1-develop.
|
|
65
|
-
"@open-mercato/shared": "0.11.1-develop.
|
|
66
|
-
"@open-mercato/telemetry": "0.11.1-develop.
|
|
63
|
+
"@open-mercato/events": "0.11.1-develop.8515.1.881743bf13",
|
|
64
|
+
"@open-mercato/queue": "0.11.1-develop.8515.1.881743bf13",
|
|
65
|
+
"@open-mercato/shared": "0.11.1-develop.8515.1.881743bf13",
|
|
66
|
+
"@open-mercato/telemetry": "0.11.1-develop.8515.1.881743bf13",
|
|
67
67
|
"cross-spawn": "^7.0.6",
|
|
68
68
|
"minisearch": "7.2.0",
|
|
69
69
|
"pg": "8.23.0",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"typescript-js": "npm:typescript@6.0.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@open-mercato/shared": "0.11.1-develop.
|
|
78
|
+
"@open-mercato/shared": "0.11.1-develop.8515.1.881743bf13"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@open-mercato/shared": "0.11.1-develop.
|
|
81
|
+
"@open-mercato/shared": "0.11.1-develop.8515.1.881743bf13",
|
|
82
82
|
"@types/jest": "^30.0.0",
|
|
83
83
|
"jest": "^30.4.2",
|
|
84
84
|
"ts-jest": "^29.4.12"
|
|
@@ -184,6 +184,78 @@ describe('module artifact inspection', () => {
|
|
|
184
184
|
expect(fs.existsSync(temporaryConfig!)).toBe(false)
|
|
185
185
|
})
|
|
186
186
|
|
|
187
|
+
function mockYarnConfigOutput(output: Record<string, string>, onPack: (args: readonly string[], npmrc: string) => void) {
|
|
188
|
+
jest.spyOn(childProcess, 'execFileSync').mockImplementation((_command, args) => args?.[0] === '-xOf'
|
|
189
|
+
? JSON.stringify({ name: '@vendor/example', version: '1.2.3' })
|
|
190
|
+
: 'package/src/modules/example/index.ts\npackage/dist/modules/example/index.js\n')
|
|
191
|
+
jest.spyOn(spawn, 'sync').mockImplementation((command, args) => {
|
|
192
|
+
if (command === 'yarn' || command === 'yarn.cmd') return { status: 0, stdout: output[String(args?.[2])], stderr: '', pid: 1, output: [], signal: null }
|
|
193
|
+
const values = args ?? []
|
|
194
|
+
onPack(values, fs.readFileSync(String(values[values.indexOf('--userconfig') + 1]), 'utf8'))
|
|
195
|
+
return { status: 0, stdout: JSON.stringify([{ name: '@vendor/example', version: '1.2.3', filename: 'candidate.tgz' }]), stderr: '', pid: 1, output: [], signal: null }
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
it.each([
|
|
200
|
+
['undefined', 'undefined\n'],
|
|
201
|
+
['empty', ''],
|
|
202
|
+
])('treats %s Yarn output for unset npmScopes and npmRegistries as not set', (_label, unset) => {
|
|
203
|
+
fs.writeFileSync(path.join(root, '.yarnrc.yml'), 'nodeLinker: node-modules\n')
|
|
204
|
+
let packArgs: readonly string[] = []
|
|
205
|
+
let npmrc = ''
|
|
206
|
+
mockYarnConfigOutput({
|
|
207
|
+
npmRegistryServer: '"https://registry.yarnpkg.com"\n',
|
|
208
|
+
npmScopes: unset,
|
|
209
|
+
npmRegistries: unset,
|
|
210
|
+
npmAuthToken: 'null\n',
|
|
211
|
+
npmAuthIdent: 'null\n',
|
|
212
|
+
}, (args, config) => { packArgs = args; npmrc = config })
|
|
213
|
+
expect(inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root)).toMatchObject({ version: '1.2.3', moduleIds: ['example'] })
|
|
214
|
+
expect(packArgs).toEqual(expect.arrayContaining(['--registry', 'https://registry.yarnpkg.com', '--@vendor:registry=https://registry.yarnpkg.com']))
|
|
215
|
+
expect(npmrc).toContain('registry="https://registry.yarnpkg.com"')
|
|
216
|
+
expect(npmrc).not.toContain('_auth')
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('keeps top-level Yarn authentication when npmScopes and npmRegistries are unset', () => {
|
|
220
|
+
fs.writeFileSync(path.join(root, '.yarnrc.yml'), 'nodeLinker: node-modules\n')
|
|
221
|
+
let npmrc = ''
|
|
222
|
+
mockYarnConfigOutput({
|
|
223
|
+
npmRegistryServer: '"https://registry.yarnpkg.com"\n',
|
|
224
|
+
npmScopes: 'undefined\n',
|
|
225
|
+
npmRegistries: 'undefined\n',
|
|
226
|
+
npmAuthToken: '"test-token-do-not-print"\n',
|
|
227
|
+
npmAuthIdent: 'null\n',
|
|
228
|
+
}, (_args, config) => { npmrc = config })
|
|
229
|
+
expect(inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root).version).toBe('1.2.3')
|
|
230
|
+
expect(npmrc).toContain('//registry.yarnpkg.com/:_authToken="test-token-do-not-print"')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('still fails closed on malformed Yarn configuration output', () => {
|
|
234
|
+
fs.writeFileSync(path.join(root, '.yarnrc.yml'), 'nodeLinker: node-modules\n')
|
|
235
|
+
mockYarnConfigOutput({
|
|
236
|
+
npmRegistryServer: '"https://registry.yarnpkg.com"\n',
|
|
237
|
+
npmScopes: 'not json test-token-do-not-print',
|
|
238
|
+
npmRegistries: 'undefined\n',
|
|
239
|
+
npmAuthToken: 'null\n',
|
|
240
|
+
npmAuthIdent: 'null\n',
|
|
241
|
+
}, () => { throw new Error('npm pack must not run') })
|
|
242
|
+
expect(() => inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root)).toThrow('while trying to read the project registry configuration. Yarn setting npmScopes returned output that is not JSON.')
|
|
243
|
+
try { inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root) } catch (error) {
|
|
244
|
+
expect(String(error)).not.toContain('test-token-do-not-print')
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('names the Yarn setting and exit code when yarn config get fails, without exposing its output', () => {
|
|
249
|
+
fs.writeFileSync(path.join(root, '.yarnrc.yml'), 'nodeLinker: node-modules\n')
|
|
250
|
+
jest.spyOn(spawn, 'sync').mockImplementation((_command, args) => args?.[2] === 'npmRegistries'
|
|
251
|
+
? { status: 1, stdout: 'test-token-do-not-print', stderr: 'test-token-do-not-print', pid: 1, output: [], signal: null }
|
|
252
|
+
: { status: 0, stdout: 'undefined\n', stderr: '', pid: 1, output: [], signal: null })
|
|
253
|
+
expect(() => inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root)).toThrow('Yarn setting npmRegistries could not be read (exit 1).')
|
|
254
|
+
try { inspectNpmModuleTarget('@vendor/example@1.2.3', '@vendor/example', root) } catch (error) {
|
|
255
|
+
expect(String(error)).not.toContain('test-token-do-not-print')
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
|
|
187
259
|
it('fails closed on unavailable inspection without exposing private tool output', () => {
|
|
188
260
|
jest.spyOn(spawn, 'sync').mockImplementation(() => { throw new Error('private registry token') })
|
|
189
261
|
expect(() => inspectNpmModuleTarget('@vendor/example@next', '@vendor/example', root)).toThrow('No package was installed')
|
|
@@ -63,6 +63,26 @@ function isModernYarnProject(appDir: string): boolean {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const YARN_SETTING_UNREADABLE = 'YARN_SETTING_UNREADABLE'
|
|
67
|
+
|
|
68
|
+
function yarnSettingError(message: string): Error {
|
|
69
|
+
return Object.assign(new Error(message), { code: YARN_SETTING_UNREADABLE })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isYarnSettingError(error: unknown): error is Error {
|
|
73
|
+
return error instanceof Error && 'code' in error && error.code === YARN_SETTING_UNREADABLE
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function parseYarnConfigValue(setting: string, stdout: string): unknown {
|
|
77
|
+
const output = stdout.trim()
|
|
78
|
+
if (output === '' || output === 'undefined') return undefined
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(output)
|
|
81
|
+
} catch {
|
|
82
|
+
throw yarnSettingError(`Yarn setting ${setting} returned output that is not JSON.`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
66
86
|
function yarnNpmConfiguration(appDir: string, packageName: string, temporaryDir: string): string[] {
|
|
67
87
|
if (!isModernYarnProject(appDir)) return []
|
|
68
88
|
const settings = new Map<string, unknown>()
|
|
@@ -70,8 +90,8 @@ function yarnNpmConfiguration(appDir: string, packageName: string, temporaryDir:
|
|
|
70
90
|
const result = spawn.sync(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', ['config', 'get', setting, '--json', '--no-redacted'], {
|
|
71
91
|
cwd: appDir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 15_000,
|
|
72
92
|
})
|
|
73
|
-
if (result.error || result.status !== 0) throw
|
|
74
|
-
settings.set(setting,
|
|
93
|
+
if (result.error || result.status !== 0) throw yarnSettingError(`Yarn setting ${setting} could not be read (exit ${result.status ?? 'none'}).`)
|
|
94
|
+
settings.set(setting, parseYarnConfigValue(setting, result.stdout))
|
|
75
95
|
}
|
|
76
96
|
const scope = packageName.startsWith('@') ? packageName.slice(1).split('/')[0] : undefined
|
|
77
97
|
const scopeSettings = scope ? record(record(settings.get('npmScopes'))[scope]) : {}
|
|
@@ -125,7 +145,7 @@ export function inspectNpmModuleTarget(packageSpec: string, packageName: string,
|
|
|
125
145
|
if (inspected.version !== packed.version) throw new Error('Packed artifact version disagrees with resolution')
|
|
126
146
|
return { packageName, packageSpec, ...inspected, locator: `npm:${packageName}` }
|
|
127
147
|
} catch (error) {
|
|
128
|
-
const safeDetail = isModulePackageExportError(error) && error instanceof Error ? ` ${error.message}` : ''
|
|
148
|
+
const safeDetail = (isModulePackageExportError(error) || isYarnSettingError(error)) && error instanceof Error ? ` ${error.message}` : ''
|
|
129
149
|
throw new Error(`Cannot inspect the exact module artifact for "${packageName}" while trying to ${inspectionStep}.${safeDetail} Check project registry credentials, package access and shipped src/dist module descriptors before retrying. No package was installed.`)
|
|
130
150
|
} finally {
|
|
131
151
|
fs.rmSync(temporaryDir, { recursive: true, force: true })
|