@ms-cloudpack/cli 0.50.2 → 0.51.0
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/lib/commands/info/index.d.ts +4 -0
- package/lib/commands/info/index.d.ts.map +1 -0
- package/lib/commands/info/index.js +28 -0
- package/lib/commands/info/index.js.map +1 -0
- package/lib/commands/info/lockFile/checkResolvedVersions.d.ts +7 -0
- package/lib/commands/info/lockFile/checkResolvedVersions.d.ts.map +1 -0
- package/lib/commands/info/lockFile/checkResolvedVersions.js +56 -0
- package/lib/commands/info/lockFile/checkResolvedVersions.js.map +1 -0
- package/lib/commands/info/lockFile/execute.d.ts +7 -0
- package/lib/commands/info/lockFile/execute.d.ts.map +1 -0
- package/lib/commands/info/lockFile/execute.js +30 -0
- package/lib/commands/info/lockFile/execute.js.map +1 -0
- package/lib/commands/info/lockFile/processYarnLock.d.ts +7 -0
- package/lib/commands/info/lockFile/processYarnLock.d.ts.map +1 -0
- package/lib/commands/info/lockFile/processYarnLock.js +42 -0
- package/lib/commands/info/lockFile/processYarnLock.js.map +1 -0
- package/lib/commands/info/lockFile/readYarnLock.d.ts +9 -0
- package/lib/commands/info/lockFile/readYarnLock.d.ts.map +1 -0
- package/lib/commands/info/lockFile/readYarnLock.js +29 -0
- package/lib/commands/info/lockFile/readYarnLock.js.map +1 -0
- package/lib/commands/info/lockFile/types/ResolvedVersions.d.ts +31 -0
- package/lib/commands/info/lockFile/types/ResolvedVersions.d.ts.map +1 -0
- package/lib/commands/info/lockFile/types/ResolvedVersions.js +2 -0
- package/lib/commands/info/lockFile/types/ResolvedVersions.js.map +1 -0
- package/lib/commands/info/nonSemverDeps/execute.d.ts +8 -0
- package/lib/commands/info/nonSemverDeps/execute.d.ts.map +1 -0
- package/lib/commands/info/nonSemverDeps/execute.js +20 -0
- package/lib/commands/info/nonSemverDeps/execute.js.map +1 -0
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.d.ts +12 -0
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.d.ts.map +1 -0
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js +58 -0
- package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js.map +1 -0
- package/lib/commands/init/evaluateImportsForOverrides.d.ts +8 -3
- package/lib/commands/init/evaluateImportsForOverrides.d.ts.map +1 -1
- package/lib/commands/init/evaluateImportsForOverrides.js +16 -5
- package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
- package/lib/commands/init/evaluatePath.d.ts +9 -1
- package/lib/commands/init/evaluatePath.d.ts.map +1 -1
- package/lib/commands/init/evaluatePath.js +6 -2
- package/lib/commands/init/evaluatePath.js.map +1 -1
- package/lib/commands/init/init.d.ts.map +1 -1
- package/lib/commands/init/init.js +15 -12
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/init/types/InitOptions.d.ts +1 -1
- package/lib/commands/init/types/InitOptions.js.map +1 -1
- package/lib/commands/start/appServer/inlineScripts/defineProcess.inline.d.ts +2 -0
- package/lib/commands/start/appServer/inlineScripts/defineProcess.inline.d.ts.map +1 -0
- package/lib/commands/start/appServer/inlineScripts/defineProcess.inline.js +8 -0
- package/lib/commands/start/appServer/inlineScripts/defineProcess.inline.js.map +1 -0
- package/lib/commands/start/appServer/inlineScripts/getInlineScripts.js +1 -1
- package/lib/commands/start/appServer/inlineScripts/getInlineScripts.js.map +1 -1
- package/package.json +13 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAyBlB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
import { createCommand } from '../../common/createCommand.js';
|
|
3
|
+
/** Defines the "info" verb. */
|
|
4
|
+
export const init = (program) => {
|
|
5
|
+
const command = createCommand({
|
|
6
|
+
parent: program,
|
|
7
|
+
name: 'info',
|
|
8
|
+
description: 'Get repo info relevant to cloudpack (requires a sub-command).',
|
|
9
|
+
});
|
|
10
|
+
command.usage('<command>');
|
|
11
|
+
const lockfileCommand = createCommand({
|
|
12
|
+
parent: command,
|
|
13
|
+
name: 'lock-file',
|
|
14
|
+
description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',
|
|
15
|
+
getExecutor: () => import('./lockFile/execute.js'),
|
|
16
|
+
});
|
|
17
|
+
lockfileCommand.alias('lockfile');
|
|
18
|
+
createCommand({
|
|
19
|
+
parent: command,
|
|
20
|
+
name: 'non-semver-deps',
|
|
21
|
+
description: 'Get a list of non-semver deps from local packages.',
|
|
22
|
+
getExecutor: () => import('./nonSemverDeps/execute.js'),
|
|
23
|
+
options: {
|
|
24
|
+
prod: new Option('--prod', 'Only get production deps'),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,+DAA+D;KAC7E,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE3B,MAAM,eAAe,GAAG,aAAa,CAAC;QACpC,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,gFAAgF;QAC7F,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACnD,CAAC,CAAC;IACH,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAElC,aAAa,CAAC;QACZ,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC;QACvD,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC;SACvD;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport { createCommand } from '../../common/createCommand.js';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\n\n/** Defines the \"info\" verb. */\nexport const init: CommandInitFunction = (program) => {\n const command = createCommand({\n parent: program,\n name: 'info',\n description: 'Get repo info relevant to cloudpack (requires a sub-command).',\n });\n command.usage('<command>');\n\n const lockfileCommand = createCommand({\n parent: command,\n name: 'lock-file',\n description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',\n getExecutor: () => import('./lockFile/execute.js'),\n });\n lockfileCommand.alias('lockfile');\n\n createCommand({\n parent: command,\n name: 'non-semver-deps',\n description: 'Get a list of non-semver deps from local packages.',\n getExecutor: () => import('./nonSemverDeps/execute.js'),\n options: {\n prod: new Option('--prod', 'Only get production deps'),\n },\n });\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedVersions } from './types/ResolvedVersions.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check resolved versions from the lock file for potential issues.
|
|
4
|
+
* @returns A message describing any issues found.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkResolvedVersions(resolvedVersions: ResolvedVersions): string;
|
|
7
|
+
//# sourceMappingURL=checkResolvedVersions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkResolvedVersions.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/checkResolvedVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAuB,MAAM,6BAA6B,CAAC;AAEzF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,MAAM,CAqDhF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { bulletedList } from '@ms-cloudpack/task-reporter';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
/**
|
|
4
|
+
* Check resolved versions from the lock file for potential issues.
|
|
5
|
+
* @returns A message describing any issues found.
|
|
6
|
+
*/
|
|
7
|
+
export function checkResolvedVersions(resolvedVersions) {
|
|
8
|
+
// What the lock file tells you:
|
|
9
|
+
// - non-semver specs used
|
|
10
|
+
// - if two specs resolved to the same package (name, version, and URL)
|
|
11
|
+
// - if non-semver specs overlap but one is renamed, it's ok
|
|
12
|
+
// What it doesn't tell you:
|
|
13
|
+
// - installation layout
|
|
14
|
+
// - if multiple versions are present, don't know which is hoisted (or any nohoist);
|
|
15
|
+
// a non-semver version not being hoisted might resolve an overlap
|
|
16
|
+
// - where the weird dep came from (without walking the dependency graph)
|
|
17
|
+
const messages = [];
|
|
18
|
+
for (const { name, version, specs } of Object.values(resolvedVersions)) {
|
|
19
|
+
const issues = [];
|
|
20
|
+
const semverSpecs = specs.filter((spec) => !!semver.validRange(spec.specVersion));
|
|
21
|
+
const forcedSpecs = semverSpecs.filter((spec) => !semver.satisfies(version, spec.specVersion));
|
|
22
|
+
if (forcedSpecs.length) {
|
|
23
|
+
// Cloudpack attempts to handle this, but there may be some places which rely on semver checks
|
|
24
|
+
issues.push('Resolutions violating semver:', getStrings({ specs: forcedSpecs, name }));
|
|
25
|
+
}
|
|
26
|
+
if (semverSpecs.length !== specs.length) {
|
|
27
|
+
// Whether or not this will be an issue depends on a lot of details.
|
|
28
|
+
// There are enough permutations of possible issues that it's hard to have distinct logs
|
|
29
|
+
// for all cases, so just go with a general list that includes relevant info.
|
|
30
|
+
issues.push(semverSpecs.length ? 'Mix of semver and non-semver specs:' : 'Non-semver specs:');
|
|
31
|
+
issues.push(getStrings({
|
|
32
|
+
specs,
|
|
33
|
+
name,
|
|
34
|
+
// Only include the URL if there are specs with different URLs (reduces noise)
|
|
35
|
+
includeUrl: specs.some((spec) => spec.url !== specs[0].url),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
if (issues.length) {
|
|
39
|
+
messages.push([`${name} (${version})`, issues]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (messages.length) {
|
|
43
|
+
return ('Found possible issues with dependencies based on lock file ' +
|
|
44
|
+
'(use "yarn why" to figure out where these came from):\n\n' +
|
|
45
|
+
bulletedList(messages) +
|
|
46
|
+
'\n');
|
|
47
|
+
}
|
|
48
|
+
return 'No issues found';
|
|
49
|
+
}
|
|
50
|
+
function getStrings(params) {
|
|
51
|
+
const { specs, name, includeUrl } = params;
|
|
52
|
+
return specs.map(({ specVersion, realName = name, url }) => specVersion +
|
|
53
|
+
(realName !== name ? ` (real name: ${realName})` : '') +
|
|
54
|
+
(includeUrl && url ? ` resolved to ${url}` : ''));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=checkResolvedVersions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkResolvedVersions.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/checkResolvedVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,6BAA6B,CAAC;AAC5E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,gBAAkC;IACtE,gCAAgC;IAChC,0BAA0B;IAC1B,uEAAuE;IACvE,8DAA8D;IAC9D,4BAA4B;IAC5B,wBAAwB;IACxB,sFAAsF;IACtF,sEAAsE;IACtE,yEAAyE;IAEzE,MAAM,QAAQ,GAAe,E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AAC,CAAC;SACjD;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,OAAO,CACL,6DAA6D;YAC7D,2DAA2D;YAC3D,YAAY,CAAC,QAAQ,CAAC;YACtB,IAAI,CACL,CAAC;KACH;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,UAAU,CAAC,MAA4E;IAC9F,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC3C,OAAO,KAAK,CAAC,GAAG,CACd,CAAC,EAAE,WAAW,EAAE,QAAQ,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CACxC,WAAW;QACX,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACnD,CAAC;AACJ,CAAC","sourcesContent":["import { bulletedList, type BulletList } from '@ms-cloudpack/task-reporter';\nimport semver from 'semver';\nimport type { ResolvedVersions, ResolvedVersionSpec } from './types/ResolvedVersions.js';\n\n/**\n * Check resolved versions from the lock file for potential issues.\n * @returns A message describing any issues found.\n */\nexport function checkResolvedVersions(resolvedVersions: ResolvedVersions): string {\n // What the lock file tells you:\n // - non-semver specs used\n // - if two specs resolved to the same package (name, version, and URL)\n // - if non-semver specs overlap but one is renamed, it's ok\n // What it doesn't tell you:\n // - installation layout\n // - if multiple versions are present, don't know which is hoisted (or any nohoist);\n // a non-semver version not being hoisted might resolve an overlap\n // - where the weird dep came from (without walking the dependency graph)\n\n const messages: BulletList = [];\n\n for (const { name, version, specs } of Object.values(resolvedVersions)) {\n const issues: BulletList = [];\n\n const semverSpecs = specs.filter((spec) => !!semver.validRange(spec.specVersion));\n const forcedSpecs = semverSpecs.filter((spec) => !semver.satisfies(version, spec.specVersion));\n\n if (forcedSpecs.length) {\n // Cloudpack attempts to handle this, but there may be some places which rely on semver checks\n issues.push('Resolutions violating semver:', getStrings({ specs: forcedSpecs, name }));\n }\n\n if (semverSpecs.length !== specs.length) {\n // Whether or not this will be an issue depends on a lot of details.\n // There are enough permutations of possible issues that it's hard to have distinct logs\n // for all cases, so just go with a general list that includes relevant info.\n issues.push(semverSpecs.length ? 'Mix of semver and non-semver specs:' : 'Non-semver specs:');\n issues.push(\n getStrings({\n specs,\n name,\n // Only include the URL if there are specs with different URLs (reduces noise)\n includeUrl: specs.some((spec) => spec.url !== specs[0].url),\n }),\n );\n }\n\n if (issues.length) {\n messages.push([`${name} (${version})`, issues]);\n }\n }\n\n if (messages.length) {\n return (\n 'Found possible issues with dependencies based on lock file ' +\n '(use \"yarn why\" to figure out where these came from):\\n\\n' +\n bulletedList(messages) +\n '\\n'\n );\n }\n return 'No issues found';\n}\n\nfunction getStrings(params: { specs: ResolvedVersionSpec[]; name: string; includeUrl?: boolean }): string[] {\n const { specs, name, includeUrl } = params;\n return specs.map(\n ({ specVersion, realName = name, url }) =>\n specVersion +\n (realName !== name ? ` (real name: ${realName})` : '') +\n (includeUrl && url ? ` resolved to ${url}` : ''),\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandAction } from '../../../types/CommandAction.js';
|
|
2
|
+
interface LockFileOptions {
|
|
3
|
+
}
|
|
4
|
+
/** Executor for the "info lock-file" verb */
|
|
5
|
+
export declare const execute: CommandAction<LockFileOptions>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAKrE,UAAU,eAAe;CAAG;AAE5B,6CAA6C;AAC7C,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,eAAe,CAyBlD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { checkResolvedVersions } from './checkResolvedVersions.js';
|
|
2
|
+
import { readYarnLock } from './readYarnLock.js';
|
|
3
|
+
import { processYarnLock } from './processYarnLock.js';
|
|
4
|
+
/** Executor for the "info lock-file" verb */
|
|
5
|
+
export const execute = async ({ options, initialize, exit }) => {
|
|
6
|
+
const { cwd } = options;
|
|
7
|
+
await initialize({ appPath: cwd });
|
|
8
|
+
let message;
|
|
9
|
+
let success = false;
|
|
10
|
+
try {
|
|
11
|
+
// This returns either the lock file contents or an error message
|
|
12
|
+
const lockResult = await readYarnLock(cwd);
|
|
13
|
+
if (typeof lockResult === 'string') {
|
|
14
|
+
message = lockResult;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const resolvedVersions = processYarnLock(lockResult);
|
|
18
|
+
message = checkResolvedVersions(resolvedVersions);
|
|
19
|
+
success = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
message = `Error getting info from lockfile: ${err.stack || err}`;
|
|
24
|
+
}
|
|
25
|
+
await exit({
|
|
26
|
+
exitCode: success ? 0 : 1,
|
|
27
|
+
message,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAmC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7F,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,OAAe,CAAC;IACpB,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,IAAI;QACF,iEAAiE;QACjE,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,OAAO,GAAG,UAAU,CAAC;SACtB;aAAM;YACL,MAAM,gBAAgB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;YACrD,OAAO,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;YAClD,OAAO,GAAG,IAAI,CAAC;SAChB;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,GAAG,qCAAsC,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;KAC9E;IAED,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../../types/CommandAction.js';\nimport { checkResolvedVersions } from './checkResolvedVersions.js';\nimport { readYarnLock } from './readYarnLock.js';\nimport { processYarnLock } from './processYarnLock.js';\n\ninterface LockFileOptions {}\n\n/** Executor for the \"info lock-file\" verb */\nexport const execute: CommandAction<LockFileOptions> = async ({ options, initialize, exit }) => {\n const { cwd } = options;\n await initialize({ appPath: cwd });\n\n let message: string;\n let success = false;\n\n try {\n // This returns either the lock file contents or an error message\n const lockResult = await readYarnLock(cwd);\n if (typeof lockResult === 'string') {\n message = lockResult;\n } else {\n const resolvedVersions = processYarnLock(lockResult);\n message = checkResolvedVersions(resolvedVersions);\n success = true;\n }\n } catch (err) {\n message = `Error getting info from lockfile: ${(err as Error).stack || err}`;\n }\n\n await exit({\n exitCode: success ? 0 : 1,\n message,\n });\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LockFileObject } from '@yarnpkg/lockfile';
|
|
2
|
+
import type { ResolvedVersions } from './types/ResolvedVersions.js';
|
|
3
|
+
/**
|
|
4
|
+
* Process yarn.lock file contents into a map of resolved package name+version.
|
|
5
|
+
*/
|
|
6
|
+
export declare function processYarnLock(lockFile: LockFileObject): ResolvedVersions;
|
|
7
|
+
//# sourceMappingURL=processYarnLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processYarnLock.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/processYarnLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAuB,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEzF;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,gBAAgB,CAuC1E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process yarn.lock file contents into a map of resolved package name+version.
|
|
3
|
+
*/
|
|
4
|
+
export function processYarnLock(lockFile) {
|
|
5
|
+
const installedVersions = {};
|
|
6
|
+
// Examples of LockFileObject entries:
|
|
7
|
+
// 'prettier-2@npm:prettier@2': {
|
|
8
|
+
// version: '2.8.8',
|
|
9
|
+
// resolved: 'https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da',
|
|
10
|
+
// },
|
|
11
|
+
// 'weird-stuff@file:weird-stuff': { version: '1.0.0' },
|
|
12
|
+
// 'zod@^3.21.4': {
|
|
13
|
+
// version: '3.22.4',
|
|
14
|
+
// resolved: 'https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff',
|
|
15
|
+
// },
|
|
16
|
+
for (const [spec, { version, resolved }] of Object.entries(lockFile)) {
|
|
17
|
+
const atIndex = spec.indexOf('@', 1);
|
|
18
|
+
const name = spec.slice(0, atIndex);
|
|
19
|
+
const specVersion = spec.slice(atIndex + 1);
|
|
20
|
+
const specEntry = { specVersion };
|
|
21
|
+
const installedSpec = `${name}@${version}`;
|
|
22
|
+
installedVersions[installedSpec] ??= { name, version, specs: [] };
|
|
23
|
+
installedVersions[installedSpec].specs.push(specEntry);
|
|
24
|
+
// https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf
|
|
25
|
+
// https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66
|
|
26
|
+
// https://registry.yarnpkg.com/@azure/core-tracing/-/core-tracing-1.0.0-preview.13.tgz#55883d40ae2042f6f1e12b17dd0c0d34c536d644
|
|
27
|
+
// https://example.pkgs.visualstudio.com/_packaging/Example/npm/registry/@foo/bar/-/bar-1.9.2.tgz#55883d40ae2042f6f1e12b17dd0c0d34c536d644
|
|
28
|
+
try {
|
|
29
|
+
const segments = new URL(resolved || '').pathname.split('/');
|
|
30
|
+
specEntry.url = resolved;
|
|
31
|
+
const [scope, unscopedName, dash, file] = segments.slice(-4);
|
|
32
|
+
if (dash === '-' && file === `${unscopedName}-${version}.tgz`) {
|
|
33
|
+
specEntry.realName = scope.startsWith('@') ? `${scope}/${unscopedName}` : unscopedName;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// ignore URL parsing error (not all entries have a URL)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return installedVersions;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=processYarnLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processYarnLock.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/processYarnLock.ts"],"names":[],"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CAAC;YAC7D,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,YAAY,IAAI,OAAO,MAAM,EAAE;gBAC7D,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;aACxF;SACF;QAAC,MAAM;YACN,wDAAwD;SACzD;KACF;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { LockFileObject } from '@yarnpkg/lockfile';\nimport type { ResolvedVersionSpec, ResolvedVersions } from './types/ResolvedVersions.js';\n\n/**\n * Process yarn.lock file contents into a map of resolved package name+version.\n */\nexport function processYarnLock(lockFile: LockFileObject): ResolvedVersions {\n const installedVersions: ResolvedVersions = {};\n\n // Examples of LockFileObject entries:\n // 'prettier-2@npm:prettier@2': {\n // version: '2.8.8',\n // resolved: 'https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da',\n // },\n // 'weird-stuff@file:weird-stuff': { version: '1.0.0' },\n // 'zod@^3.21.4': {\n // version: '3.22.4',\n // resolved: 'https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff',\n // },\n for (const [spec, { version, resolved }] of Object.entries(lockFile)) {\n const atIndex = spec.indexOf('@', 1);\n const name = spec.slice(0, atIndex);\n const specVersion = spec.slice(atIndex + 1);\n const specEntry: ResolvedVersionSpec = { specVersion };\n const installedSpec = `${name}@${version}` as const;\n installedVersions[installedSpec] ??= { name, version, specs: [] };\n installedVersions[installedSpec].specs.push(specEntry);\n\n // https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf\n // https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66\n // https://registry.yarnpkg.com/@azure/core-tracing/-/core-tracing-1.0.0-preview.13.tgz#55883d40ae2042f6f1e12b17dd0c0d34c536d644\n // https://example.pkgs.visualstudio.com/_packaging/Example/npm/registry/@foo/bar/-/bar-1.9.2.tgz#55883d40ae2042f6f1e12b17dd0c0d34c536d644\n try {\n const segments = new URL(resolved || '').pathname.split('/');\n specEntry.url = resolved;\n const [scope, unscopedName, dash, file] = segments.slice(-4);\n if (dash === '-' && file === `${unscopedName}-${version}.tgz`) {\n specEntry.realName = scope.startsWith('@') ? `${scope}/${unscopedName}` : unscopedName;\n }\n } catch {\n // ignore URL parsing error (not all entries have a URL)\n }\n }\n\n return installedVersions;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LockFileObject } from '@yarnpkg/lockfile';
|
|
2
|
+
/**
|
|
3
|
+
* Read and parse the yarn v1 lock file at the project root (usually git root), if it exists.
|
|
4
|
+
* @param cwd Find the project root from here.
|
|
5
|
+
* @returns Parsed lock file contents if repo uses yarn v1 and parsing was successful,
|
|
6
|
+
* or an error message otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readYarnLock(cwd: string): Promise<string | LockFileObject>;
|
|
9
|
+
//# sourceMappingURL=readYarnLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readYarnLock.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/readYarnLock.ts"],"names":[],"mappings":"AAKA,OAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,CAmBhF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fsPromises from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { findProjectRoot } from 'workspace-tools';
|
|
5
|
+
// This module doesn't actually provide named exports for functions (types are wrong)
|
|
6
|
+
import yarnLock, {} from '@yarnpkg/lockfile';
|
|
7
|
+
/**
|
|
8
|
+
* Read and parse the yarn v1 lock file at the project root (usually git root), if it exists.
|
|
9
|
+
* @param cwd Find the project root from here.
|
|
10
|
+
* @returns Parsed lock file contents if repo uses yarn v1 and parsing was successful,
|
|
11
|
+
* or an error message otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export async function readYarnLock(cwd) {
|
|
14
|
+
const projectRoot = findProjectRoot(cwd);
|
|
15
|
+
const yarnLockPath = path.join(projectRoot, 'yarn.lock');
|
|
16
|
+
if (!fs.existsSync(yarnLockPath)) {
|
|
17
|
+
return `${yarnLockPath} not found (this command only works with Yarn 1)`;
|
|
18
|
+
}
|
|
19
|
+
const lockContents = await fsPromises.readFile(yarnLockPath, 'utf8');
|
|
20
|
+
if (!lockContents.includes('# yarn lockfile v1')) {
|
|
21
|
+
return 'This command only works with Yarn 1';
|
|
22
|
+
}
|
|
23
|
+
const lockfile = yarnLock.parse(lockContents);
|
|
24
|
+
if (lockfile.type === 'success') {
|
|
25
|
+
return lockfile.object;
|
|
26
|
+
}
|
|
27
|
+
return `Error parsing lockfile (${lockfile.type})`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=readYarnLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readYarnLock.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/readYarnLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,qFAAqF;AACrF,OAAO,QAAQ,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEzC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAChC,OAAO,GAAG,YAAY,kDAAkD,CAAC;KAC1E;IAED,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE;QAChD,OAAO,qCAAqC,CAAC;KAC9C;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;QAC/B,OAAO,QAAQ,CAAC,MAAM,CAAC;KACxB;IAED,OAAO,2BAA2B,QAAQ,CAAC,IAAI,GAAG,CAAC;AACrD,CAAC","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { findProjectRoot } from 'workspace-tools';\n// This module doesn't actually provide named exports for functions (types are wrong)\nimport yarnLock, { type LockFileObject } from '@yarnpkg/lockfile';\n\n/**\n * Read and parse the yarn v1 lock file at the project root (usually git root), if it exists.\n * @param cwd Find the project root from here.\n * @returns Parsed lock file contents if repo uses yarn v1 and parsing was successful,\n * or an error message otherwise.\n */\nexport async function readYarnLock(cwd: string): Promise<string | LockFileObject> {\n const projectRoot = findProjectRoot(cwd);\n\n const yarnLockPath = path.join(projectRoot, 'yarn.lock');\n if (!fs.existsSync(yarnLockPath)) {\n return `${yarnLockPath} not found (this command only works with Yarn 1)`;\n }\n\n const lockContents = await fsPromises.readFile(yarnLockPath, 'utf8');\n if (!lockContents.includes('# yarn lockfile v1')) {\n return 'This command only works with Yarn 1';\n }\n\n const lockfile = yarnLock.parse(lockContents);\n if (lockfile.type === 'success') {\n return lockfile.object;\n }\n\n return `Error parsing lockfile (${lockfile.type})`;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Info about each resolved package+version per the lockfile.
|
|
3
|
+
* Key is `${name}@${version}`.
|
|
4
|
+
*/
|
|
5
|
+
export type ResolvedVersions = Record<`${string}@${string}`, ResolvedVersion>;
|
|
6
|
+
/**
|
|
7
|
+
* Info about a resolved package+version per the lockfile.
|
|
8
|
+
*/
|
|
9
|
+
export interface ResolvedVersion {
|
|
10
|
+
/** Name that's listed under "dependencies" and installed on disk */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Resolved version */
|
|
13
|
+
version: string;
|
|
14
|
+
/** Different specs that resolved to this version */
|
|
15
|
+
specs: ResolvedVersionSpec[];
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvedVersionSpec {
|
|
18
|
+
/** Requested version, e.g. `^1.2.3` */
|
|
19
|
+
specVersion: string;
|
|
20
|
+
/**
|
|
21
|
+
* Actual name of the package, determined from the npm feed URL if available.
|
|
22
|
+
* This will almost always be the same as `ResolvedVersion.name`.
|
|
23
|
+
*/
|
|
24
|
+
realName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Resolved URL. This will almost always be the same across specs resolving to a given version.
|
|
27
|
+
* If it's different, this means the specs will be located at different paths on disk.
|
|
28
|
+
*/
|
|
29
|
+
url?: string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ResolvedVersions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedVersions.d.ts","sourceRoot":"","sources":["../../../../../src/commands/info/lockFile/types/ResolvedVersions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedVersions.js","sourceRoot":"","sources":["../../../../../src/commands/info/lockFile/types/ResolvedVersions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Info about each resolved package+version per the lockfile.\n * Key is `${name}@${version}`.\n */\nexport type ResolvedVersions = Record<`${string}@${string}`, ResolvedVersion>;\n\n/**\n * Info about a resolved package+version per the lockfile.\n */\nexport interface ResolvedVersion {\n /** Name that's listed under \"dependencies\" and installed on disk */\n name: string;\n /** Resolved version */\n version: string;\n /** Different specs that resolved to this version */\n specs: ResolvedVersionSpec[];\n}\n\nexport interface ResolvedVersionSpec {\n /** Requested version, e.g. `^1.2.3` */\n specVersion: string;\n /**\n * Actual name of the package, determined from the npm feed URL if available.\n * This will almost always be the same as `ResolvedVersion.name`.\n */\n realName?: string;\n /**\n * Resolved URL. This will almost always be the same across specs resolving to a given version.\n * If it's different, this means the specs will be located at different paths on disk.\n */\n url?: string;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommandAction } from '../../../types/CommandAction.js';
|
|
2
|
+
export interface NonSemverDepsOptions {
|
|
3
|
+
/** Only get production deps */
|
|
4
|
+
prod?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Executor for the "info non-semver-deps" verb */
|
|
7
|
+
export declare const execute: CommandAction<NonSemverDepsOptions>;
|
|
8
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGrE,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,mDAAmD;AACnD,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAkBvD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getNonSemverDeps } from './getNonSemverDeps.js';
|
|
2
|
+
/** Executor for the "info non-semver-deps" verb */
|
|
3
|
+
export const execute = async ({ options, initialize, exit }) => {
|
|
4
|
+
const { cwd } = options;
|
|
5
|
+
await initialize({ appPath: cwd });
|
|
6
|
+
let message;
|
|
7
|
+
let success = false;
|
|
8
|
+
try {
|
|
9
|
+
message = await getNonSemverDeps(options);
|
|
10
|
+
success = true;
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
message = `Error attempting to get non-semver deps: ${err.stack || err}`;
|
|
14
|
+
}
|
|
15
|
+
await exit({
|
|
16
|
+
exitCode: success ? 0 : 1,
|
|
17
|
+
message,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD,mDAAmD;AACnD,MAAM,CAAC,MAAM,OAAO,GAAwC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;IAClG,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,OAAe,CAAC;IACpB,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,IAAI;QACF,OAAO,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,GAAG,IAAI,CAAC;KAChB;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,GAAG,4CAA6C,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;KACrF;IAED,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../../types/CommandAction.js';\nimport { getNonSemverDeps } from './getNonSemverDeps.js';\n\nexport interface NonSemverDepsOptions {\n /** Only get production deps */\n prod?: boolean;\n}\n\n/** Executor for the \"info non-semver-deps\" verb */\nexport const execute: CommandAction<NonSemverDepsOptions> = async ({ options, initialize, exit }) => {\n const { cwd } = options;\n await initialize({ appPath: cwd });\n\n let message: string;\n let success = false;\n\n try {\n message = await getNonSemverDeps(options);\n success = true;\n } catch (err) {\n message = `Error attempting to get non-semver deps: ${(err as Error).stack || err}`;\n }\n\n await exit({\n exitCode: success ? 0 : 1,\n message,\n });\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check the local packages in the monorepo for non-semver deps.
|
|
3
|
+
* Returns either a table of those deps or a message saying there are none.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getNonSemverDeps(params: {
|
|
6
|
+
cwd: string;
|
|
7
|
+
/** Only include production dependencies */
|
|
8
|
+
prod?: boolean;
|
|
9
|
+
/** Use this directoy as the root instead of calling `findProjectRoot` (for testing) */
|
|
10
|
+
overrideProjectRoot?: string;
|
|
11
|
+
}): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=getNonSemverDeps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNonSemverDeps.d.ts","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/getNonSemverDeps.ts"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAkDlB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import { table } from '@ms-cloudpack/task-reporter';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import { findProjectRoot, getPackageInfos } from 'workspace-tools';
|
|
6
|
+
// resolutions might apply to prod or dev dependencies, so include it just in case
|
|
7
|
+
const prodDeps = ['dependencies', 'peerDependencies', 'resolutions'];
|
|
8
|
+
const allDeps = [...prodDeps, 'devDependencies'];
|
|
9
|
+
const depTypeNames = {
|
|
10
|
+
dependencies: 'prod',
|
|
11
|
+
peerDependencies: 'peer',
|
|
12
|
+
devDependencies: 'dev',
|
|
13
|
+
resolutions: 'resolution',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Check the local packages in the monorepo for non-semver deps.
|
|
17
|
+
* Returns either a table of those deps or a message saying there are none.
|
|
18
|
+
*/
|
|
19
|
+
export async function getNonSemverDeps(params) {
|
|
20
|
+
const { cwd, prod, overrideProjectRoot } = params;
|
|
21
|
+
const projectRoot = overrideProjectRoot || findProjectRoot(cwd);
|
|
22
|
+
const packages = getPackageInfos(projectRoot);
|
|
23
|
+
// add the root package.json to the package infos
|
|
24
|
+
const rootPkgJsonPath = path.join(projectRoot, 'package.json');
|
|
25
|
+
const rootPkg = await readJson(rootPkgJsonPath);
|
|
26
|
+
if (!rootPkg) {
|
|
27
|
+
throw new Error(`${rootPkgJsonPath} does not exist`);
|
|
28
|
+
}
|
|
29
|
+
if (!rootPkg.name || !rootPkg.version) {
|
|
30
|
+
throw new Error(`${rootPkgJsonPath} is missing a name and/or version`);
|
|
31
|
+
}
|
|
32
|
+
packages[rootPkg.name] = rootPkg;
|
|
33
|
+
const depTypes = prod ? prodDeps : allDeps;
|
|
34
|
+
const nonSemverDeps = Object.values(packages)
|
|
35
|
+
.map((pkg) => depTypes
|
|
36
|
+
// get dependencies, peerDependencies, etc from the package
|
|
37
|
+
.map((dt) => Object.entries(pkg[dt] || {}).map(([name, version]) => ({ name, version, type: dt })))
|
|
38
|
+
.flat(1)
|
|
39
|
+
// get non-semver versions
|
|
40
|
+
.filter(({ version }) => !semver.validRange(version))
|
|
41
|
+
.map(({ name, version, type }) => ({
|
|
42
|
+
parent: pkg.name,
|
|
43
|
+
depName: name,
|
|
44
|
+
type: depTypeNames[type],
|
|
45
|
+
version,
|
|
46
|
+
})))
|
|
47
|
+
.flat();
|
|
48
|
+
if (!nonSemverDeps.length) {
|
|
49
|
+
return 'No non-semver dependencies found';
|
|
50
|
+
}
|
|
51
|
+
return (table(nonSemverDeps, {
|
|
52
|
+
parent: 'Parent package',
|
|
53
|
+
depName: 'Dependency',
|
|
54
|
+
type: 'Dep type',
|
|
55
|
+
version: 'Version',
|
|
56
|
+
}) + '\n');
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=getNonSemverDeps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNonSemverDeps.js","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/getNonSemverDeps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,E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CAAC,CAAC,GAAgB,EAAE,EAAE,CACxB,QAAQ;QACN,2DAA2D;SAC1D,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;SAClG,IAAI,CAAC,CAAC,CAAC;QACR,0BAA0B;SACzB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;SACpD,GAAG,CACF,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAgB,EAAE,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,CAAC,IAAI;QAChB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;QACxB,OAAO;KACR,CAAC,CACH,CACJ;SACA,IAAI,EAAE,CAAC;IAEV,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QACzB,OAAO,kCAAkC,CAAC;KAC3C;IAED,OAAO,CACL,KAAK,CAAC,aAAa,EAAE;QACnB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,SAAS;KACnB,CAAC,GAAG,IAAI,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/config-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { table } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport semver from 'semver';\nimport { findProjectRoot, getPackageInfos, type PackageInfo } from 'workspace-tools';\n\ninterface NonSemverDep {\n parent: string | undefined;\n depName: string;\n type: string;\n version: string | undefined;\n}\n\n// resolutions might apply to prod or dev dependencies, so include it just in case\nconst prodDeps = ['dependencies', 'peerDependencies', 'resolutions'] as const;\nconst allDeps = [...prodDeps, 'devDependencies'] as const;\n\nconst depTypeNames = {\n dependencies: 'prod',\n peerDependencies: 'peer',\n devDependencies: 'dev',\n resolutions: 'resolution',\n};\n\n/**\n * Check the local packages in the monorepo for non-semver deps.\n * Returns either a table of those deps or a message saying there are none.\n */\nexport async function getNonSemverDeps(params: {\n cwd: string;\n /** Only include production dependencies */\n prod?: boolean;\n /** Use this directoy as the root instead of calling `findProjectRoot` (for testing) */\n overrideProjectRoot?: string;\n}): Promise<string> {\n const { cwd, prod, overrideProjectRoot } = params;\n\n const projectRoot = overrideProjectRoot || findProjectRoot(cwd);\n const packages = getPackageInfos(projectRoot);\n\n // add the root package.json to the package infos\n const rootPkgJsonPath = path.join(projectRoot, 'package.json');\n const rootPkg = await readJson<PackageJson>(rootPkgJsonPath);\n if (!rootPkg) {\n throw new Error(`${rootPkgJsonPath} does not exist`);\n }\n if (!rootPkg.name || !rootPkg.version) {\n throw new Error(`${rootPkgJsonPath} is missing a name and/or version`);\n }\n packages[rootPkg.name] = rootPkg as PackageInfo;\n\n const depTypes = prod ? prodDeps : allDeps;\n\n const nonSemverDeps = Object.values(packages)\n .map((pkg: PackageJson) =>\n depTypes\n // get dependencies, peerDependencies, etc from the package\n .map((dt) => Object.entries(pkg[dt] || {}).map(([name, version]) => ({ name, version, type: dt })))\n .flat(1)\n // get non-semver versions\n .filter(({ version }) => !semver.validRange(version))\n .map(\n ({ name, version, type }): NonSemverDep => ({\n parent: pkg.name,\n depName: name,\n type: depTypeNames[type],\n version,\n }),\n ),\n )\n .flat();\n\n if (!nonSemverDeps.length) {\n return 'No non-semver dependencies found';\n }\n\n return (\n table(nonSemverDeps, {\n parent: 'Parent package',\n depName: 'Dependency',\n type: 'Dep type',\n version: 'Version',\n }) + '\\n'\n );\n}\n"]}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import type { DetectedImports } from '@ms-cloudpack/api-server';
|
|
2
|
-
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { PackageDefinitionsCache, PackageImporterContext } from '@ms-cloudpack/bundler-types';
|
|
3
3
|
import type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-types';
|
|
4
4
|
import type { ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
5
5
|
import type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';
|
|
6
6
|
/**
|
|
7
7
|
* Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.
|
|
8
|
-
* If so, updates package overrides
|
|
8
|
+
* If so, updates package overrides in the config.
|
|
9
9
|
*/
|
|
10
10
|
export declare function evaluateImportsForOverrides(options: {
|
|
11
11
|
packages: PackageDefinitionsCache;
|
|
12
12
|
imports: DetectedImports;
|
|
13
13
|
definition: PackageJson;
|
|
14
14
|
packagePath: string;
|
|
15
|
+
/** Config so far. This will be modified if new overrides are needed. */
|
|
15
16
|
config: CloudpackConfig;
|
|
16
17
|
resolveMap: ResolveMap;
|
|
17
18
|
}): Promise<{
|
|
19
|
+
/** Changes made to the generated config */
|
|
18
20
|
changes: GeneratedPackageChanges[];
|
|
21
|
+
/** Any errors encountered */
|
|
19
22
|
errors: string[];
|
|
20
|
-
|
|
23
|
+
/** Map from new package path (to be evaluated) to info about the parent. */
|
|
24
|
+
pathsToEvaluate: Map<string, PackageImporterContext | undefined>;
|
|
25
|
+
/** Package paths for which new exports were added, so the package should be re-processed. */
|
|
21
26
|
pathsToRefresh: Set<string>;
|
|
22
27
|
}>;
|
|
23
28
|
//# sourceMappingURL=evaluateImportsForOverrides.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAmB,MAAM,4BAA4B,CAAC;AAEhG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AASlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAElF;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC;IACV,2CAA2C;IAC3C,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACnC,6BAA6B;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IACjE,6FAA6F;IAC7F,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CA+GD"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { getPackageSettings } from '@ms-cloudpack/config';
|
|
2
|
-
import { addExportsMapEntry, findResolveMapEntry, flattenExportsMap, getExportsMap, } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
import { addExportsMapEntry, findResolveMapEntry, flattenExportsMap, getDependencies, getExportsMap, } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
import { bulletedList, cyan } from '@ms-cloudpack/task-reporter';
|
|
4
4
|
/**
|
|
5
5
|
* Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.
|
|
6
|
-
* If so, updates package overrides
|
|
6
|
+
* If so, updates package overrides in the config.
|
|
7
7
|
*/
|
|
8
8
|
export async function evaluateImportsForOverrides(options) {
|
|
9
9
|
const { packages, imports, definition, packagePath, config, resolveMap } = options;
|
|
10
10
|
const displayName = `${definition.name}@${definition.version}`;
|
|
11
11
|
const changes = [];
|
|
12
12
|
const errors = [];
|
|
13
|
-
const pathsToEvaluate = new
|
|
13
|
+
const pathsToEvaluate = new Map();
|
|
14
14
|
const pathsToRefresh = new Set();
|
|
15
|
+
const dependencyVersions = getDependencies(definition);
|
|
15
16
|
// Iterate through imports and find their path from the resolve map.
|
|
16
17
|
for (const [dependencyName, dependencyImportPaths] of Object.entries(imports)) {
|
|
17
18
|
const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });
|
|
@@ -26,8 +27,18 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
26
27
|
if (!name || !version) {
|
|
27
28
|
throw new Error(`Package "${displayName}" depends on "${dependencyName}" but it is missing a name or version.`);
|
|
28
29
|
}
|
|
30
|
+
let importerContext;
|
|
31
|
+
const versionRequirement = dependencyVersions[dependencyName];
|
|
32
|
+
if (versionRequirement && definition.name && definition.version) {
|
|
33
|
+
importerContext = {
|
|
34
|
+
parentName: definition.name,
|
|
35
|
+
parentVersion: definition.version,
|
|
36
|
+
importedName: dependencyName,
|
|
37
|
+
versionRequirement,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
29
40
|
// Make sure to add the package to the list of packages to evaluate.
|
|
30
|
-
pathsToEvaluate.
|
|
41
|
+
pathsToEvaluate.set(dependencyPath, importerContext);
|
|
31
42
|
// Get the flattened bundle-able exports map for this dependency and iterate through our import paths to ensure nothing is missing.
|
|
32
43
|
const exports = await getExportsMap({ packagePath: dependencyPath }, { packages, config });
|
|
33
44
|
const flattenedExports = flattenExportsMap(exports);
|
|
@@ -70,7 +81,7 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
70
81
|
},
|
|
71
82
|
],
|
|
72
83
|
});
|
|
73
|
-
// Since we've found a missing
|
|
84
|
+
// Since we've found a missing export, we need to re-enqueue the dependency for evaluation.
|
|
74
85
|
pathsToRefresh.add(dependencyPath);
|
|
75
86
|
}
|
|
76
87
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,OAQjD;IAUC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACnF,MAAM,WAAW,GAAG,GAAG,UA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aACjC,EACD,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrB,CAAC;YAEF,IAAI,UAAU,EAAE;gBACd,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,oBAAoB,CAAC,OAAO,IAAI,EAAE;oBAC3C,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,cAAc;4BACpB,MAAM,EAAE,oBAAoB;4BAC5B,MAAM,EAAE,gBAAgB,WAAW,GAAG;yBACvC;qBACF;iBACF,CAAC,CAAC;gBAEH,2FAA2F;gBAC3F,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;aACpC;iBAAM;gBACL,MAAM,YAAY,GAAG,aAAa,IAAI,CACpC,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAClD,0FAA0F,IAAI,CAC7F,cAAc,CACf,6DAA6D,YAAY,CACxE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,WAAW,EAAE,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,cAAc,EAAE,CAAC,EACtF,CAAC,CACF,EAAE,CAAC;gBACJ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC3B;SACF;KACF;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAC9D,CAAC","sourcesContent":["import type { DetectedImports } from '@ms-cloudpack/api-server';\nimport type { PackageDefinitionsCache, PackageImporterContext } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig, PackageJson, PackageSettings } from '@ms-cloudpack/config-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getDependencies,\n getExportsMap,\n} from '@ms-cloudpack/package-utilities';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\n/**\n * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.\n * If so, updates package overrides in the config.\n */\nexport async function evaluateImportsForOverrides(options: {\n packages: PackageDefinitionsCache;\n imports: DetectedImports;\n definition: PackageJson;\n packagePath: string;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n}): Promise<{\n /** Changes made to the generated config */\n changes: GeneratedPackageChanges[];\n /** Any errors encountered */\n errors: string[];\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n}> {\n const { packages, imports, definition, packagePath, config, resolveMap } = options;\n const displayName = `${definition.name}@${definition.version}`;\n const changes: GeneratedPackageChanges[] = [];\n const errors: string[] = [];\n const pathsToEvaluate = new Map<string, PackageImporterContext | undefined>();\n const pathsToRefresh = new Set<string>();\n const dependencyVersions = getDependencies(definition);\n\n // Iterate through imports and find their path from the resolve map.\n for (const [dependencyName, dependencyImportPaths] of Object.entries(imports)) {\n const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });\n const dependencyPath = resolveEntry?.path;\n const dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined;\n\n if (!dependencyPath || !dependencyDefinition) {\n errors.push(\n `Package \"${displayName}\" imports from the package \"${dependencyName}\" but it couldn't be found. ` +\n `Ensure that \"${dependencyName}\" is listed in dependencies of \"${displayName}\".`,\n );\n continue;\n }\n\n const { name, version } = dependencyDefinition as Required<PackageJson>;\n if (!name || !version) {\n throw new Error(`Package \"${displayName}\" depends on \"${dependencyName}\" but it is missing a name or version.`);\n }\n\n let importerContext: PackageImporterContext | undefined;\n const versionRequirement = dependencyVersions[dependencyName];\n if (versionRequirement && definition.name && definition.version) {\n importerContext = {\n parentName: definition.name,\n parentVersion: definition.version,\n importedName: dependencyName,\n versionRequirement,\n };\n }\n\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(dependencyPath, importerContext);\n\n // Get the flattened bundle-able exports map for this dependency and iterate through our import paths to ensure nothing is missing.\n const exports = await getExportsMap({ packagePath: dependencyPath }, { packages, config });\n const flattenedExports = flattenExportsMap(exports);\n const packageSettings = (config.generated.packageSettings ??= []);\n let generatedPackageSettings: PackageSettings | undefined;\n\n for (const dependencyImportPath of dependencyImportPaths) {\n if (flattenedExports[dependencyImportPath]) {\n continue;\n }\n\n // We are missing an import path. We need to add this entry to the exports map in package settings.\n generatedPackageSettings ??= getPackageSettings({\n config: { generated: { packageSettings } },\n name,\n version,\n firstMatch: true,\n }).generatedPackageSettings;\n\n if (!generatedPackageSettings) {\n generatedPackageSettings = {\n match: { name, version: `^${version}` },\n exports: {},\n };\n packageSettings.push(generatedPackageSettings);\n }\n\n generatedPackageSettings.exports ??= {};\n\n const addedEntry = await addExportsMapEntry(\n {\n exports: generatedPackageSettings.exports,\n packagePath: dependencyPath,\n importPath: dependencyImportPath,\n },\n { packages, config },\n );\n\n if (addedEntry) {\n changes.push({\n name: dependencyName,\n version: dependencyDefinition.version || '',\n path: dependencyPath,\n changes: [\n {\n type: 'added-export',\n change: dependencyImportPath,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n // Since we've found a missing export, we need to re-enqueue the dependency for evaluation.\n pathsToRefresh.add(dependencyPath);\n } else {\n const errorMessage = `Imported \"${cyan(\n dependencyImportPath.replace('.', dependencyName),\n )}\" but a corresponding file couldn't be found. Either correct the import or adjust the \"${cyan(\n dependencyName,\n )}\" package version to one that supports this import path.\\n${bulletedList(\n [`${cyan(displayName)}: ${packagePath}`, `${cyan(dependencyName)}: ${dependencyPath}`],\n 2,\n )}`;\n errors.push(errorMessage);\n }\n }\n }\n\n return { changes, errors, pathsToEvaluate, pathsToRefresh };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server/apis';
|
|
2
2
|
import type { CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
3
|
+
import type { PackageImporterContext } from '@ms-cloudpack/bundler-types';
|
|
3
4
|
import type { ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
4
5
|
import type { TelemetryClient } from '@ms-cloudpack/telemetry';
|
|
5
6
|
import type { InitSummaryData } from './InitSummaryData.js';
|
|
@@ -10,7 +11,11 @@ import type { InitOptions } from './types/InitOptions.js';
|
|
|
10
11
|
* in the generated config.
|
|
11
12
|
*/
|
|
12
13
|
export declare function evaluatePath(options: {
|
|
14
|
+
/** Path to evaluate. */
|
|
13
15
|
packagePath: string;
|
|
16
|
+
/** Info about how the parent package */
|
|
17
|
+
importerContext: PackageImporterContext | undefined;
|
|
18
|
+
/** Config so far. This will be modified if new overrides are needed. */
|
|
14
19
|
config: CloudpackConfig;
|
|
15
20
|
resolveMap: ResolveMap;
|
|
16
21
|
telemetryClient: TelemetryClient;
|
|
@@ -19,8 +24,11 @@ export declare function evaluatePath(options: {
|
|
|
19
24
|
shouldForce: boolean;
|
|
20
25
|
ctx: EnsurePackageBundledContext;
|
|
21
26
|
}): Promise<{
|
|
22
|
-
|
|
27
|
+
/** Map from new package path (to be evaluated) to info about the parent. */
|
|
28
|
+
pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;
|
|
29
|
+
/** Package paths for which new exports were added, so the package should be re-processed. */
|
|
23
30
|
pathsToRefresh?: Set<string>;
|
|
31
|
+
/** Whether a fatal error was encountered. */
|
|
24
32
|
shouldExit?: boolean;
|
|
25
33
|
}>;
|
|
26
34
|
//# sourceMappingURL=evaluatePath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluatePath.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAA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SAAS,CAAC;IACpD,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,eAAe,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,2BAA2B,CAAC;CAClC,GAAG,OAAO,CAAC;IACV,4EAA4E;IAC5E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IAClE,6FAA6F;IAC7F,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC,CAoFD"}
|
|
@@ -6,9 +6,12 @@ import { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';
|
|
|
6
6
|
* in the generated config.
|
|
7
7
|
*/
|
|
8
8
|
export async function evaluatePath(options) {
|
|
9
|
-
const { packagePath, config, initOptions, telemetryClient, resolveMap, summaryData, shouldForce, ctx } = options;
|
|
9
|
+
const { packagePath, config, initOptions, telemetryClient, resolveMap, summaryData, shouldForce, ctx, importerContext, } = options;
|
|
10
10
|
const { packages } = ctx;
|
|
11
|
-
|
|
11
|
+
// This line is the reason we have to track the importerContext for packages to evaluate:
|
|
12
|
+
// otherwise if a non-semver package is read here, we'd lose the modifications from the initial
|
|
13
|
+
// time the package was read (and getNonSemverTransform was called) when building the resolve map.
|
|
14
|
+
const definition = await packages.get(packagePath, { refresh: true, importerContext });
|
|
12
15
|
const { name, version } = definition || {};
|
|
13
16
|
if (!definition || !name || !version) {
|
|
14
17
|
// Unsure why a package would be missing a definition/name/version - we've built the resolve map already.
|
|
@@ -21,6 +24,7 @@ export async function evaluatePath(options) {
|
|
|
21
24
|
version,
|
|
22
25
|
shouldFindImports: true,
|
|
23
26
|
shouldForce,
|
|
27
|
+
shouldRerun: shouldForce,
|
|
24
28
|
},
|
|
25
29
|
ctx,
|
|
26
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAalC;IAQC,MAAM,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,GAAG,EACH,eAAe,GAChB,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IAEzB,yFAAyF;IACzF,+FAA+F;IAC/F,kGAAkG;IAClG,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;IAE3C,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;QACpC,yGAAyG;QACzG,MAAM,IAAI,KAAK,CACb,GAAG,WAAW,gGAAgG,CAC/G,CAAC;KACH;IAED,yDAAyD;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,iBAAiB,EAAE,IAAI;YACvB,WAAW;YACX,WAAW,EAAE,WAAW;SACzB;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAA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ACL,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server/apis';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { PackageImporterContext } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n telemetryClient: TelemetryClient;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n shouldForce: boolean;\n ctx: EnsurePackageBundledContext;\n}): Promise<{\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate?: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh?: Set<string>;\n /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const {\n packagePath,\n config,\n initOptions,\n telemetryClient,\n resolveMap,\n summaryData,\n shouldForce,\n ctx,\n importerContext,\n } = options;\n const { packages } = ctx;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition || {};\n\n if (!definition || !name || !version) {\n // Unsure why a package would be missing a definition/name/version - we've built the resolve map already.\n throw new Error(\n `${packagePath} evaluation failed because the package.json with a name/version was not found or not readable.`,\n );\n }\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n shouldFindImports: true,\n shouldForce,\n shouldRerun: shouldForce,\n },\n ctx,\n });\n\n const { errors, warnings, imports } = result;\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({ ...resultIdentifier, errors, warnings });\n\n // If there were errors or no imports, return early.\n if (errors?.length || !imports) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n changes,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({ definition, packagePath, packages, imports, config, resolveMap });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n ...resultIdentifier,\n errors: evalErrors.map((text) => ({ text })),\n });\n } else {\n summaryData.recordGeneratedChanges(changes);\n }\n\n if (initOptions.check && (changes.length || evalErrors.length)) {\n telemetryClient.rootSpan.addEvent('INIT_CHECK_FAILED', {\n reason: changes.length ? 'Config needs to be updated.' : evalErrors,\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA6C,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA6C,MAAM,4BAA4B,CAAC;AAG7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAQ1D;;GAEG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;IACxB,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,OAAO,CAAC,WAAW,CAAC,CA2GvB"}
|
|
@@ -35,22 +35,26 @@ export async function init(parameters) {
|
|
|
35
35
|
const refreshPaths = new Set();
|
|
36
36
|
// Start with the app path or requested matches
|
|
37
37
|
enqueuePaths(getInitialPaths({ appPath, match: options.match, resolveMap, reporter }));
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Enqueue more paths.
|
|
40
|
+
* @param newPaths Mapping from package path to importer context.
|
|
41
|
+
*/
|
|
39
42
|
function enqueuePaths(newPaths) {
|
|
40
43
|
if (isExitingPrematurely) {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
// Iterate through the given paths.
|
|
44
|
-
for (const
|
|
45
|
-
if (visitedSet.has(
|
|
47
|
+
for (const [packagePath, importerContext] of newPaths) {
|
|
48
|
+
if (visitedSet.has(packagePath)) {
|
|
46
49
|
continue;
|
|
47
50
|
}
|
|
48
|
-
const shouldForce = refreshPaths.delete(
|
|
49
|
-
visitedSet.add(
|
|
51
|
+
const shouldForce = refreshPaths.delete(packagePath);
|
|
52
|
+
visitedSet.add(packagePath);
|
|
50
53
|
pending++;
|
|
51
54
|
// Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.
|
|
52
55
|
evaluatePath({
|
|
53
|
-
packagePath
|
|
56
|
+
packagePath,
|
|
57
|
+
importerContext,
|
|
54
58
|
config,
|
|
55
59
|
telemetryClient,
|
|
56
60
|
resolveMap,
|
|
@@ -72,7 +76,7 @@ export async function init(parameters) {
|
|
|
72
76
|
visitedSet.delete(refreshPath);
|
|
73
77
|
});
|
|
74
78
|
// Try to enqueue the new paths.
|
|
75
|
-
enqueuePaths(
|
|
79
|
+
enqueuePaths(pathsToEvaluate);
|
|
76
80
|
}
|
|
77
81
|
// If nothing is pending after this call, we're complete.
|
|
78
82
|
if (!pending) {
|
|
@@ -98,13 +102,12 @@ export async function init(parameters) {
|
|
|
98
102
|
function getInitialPaths(params) {
|
|
99
103
|
const { appPath, match, resolveMap, reporter } = params;
|
|
100
104
|
if (!match) {
|
|
101
|
-
return [appPath];
|
|
105
|
+
return new Map([[appPath, undefined]]);
|
|
102
106
|
}
|
|
103
|
-
// Find
|
|
104
|
-
const
|
|
105
|
-
const resolveMapEntries = matchNames.map((name) => resolveMap[name]);
|
|
107
|
+
// Find matching packages in the resolve map
|
|
108
|
+
const resolveMapEntries = Object.values(resolveMap).filter((entry) => entry.name.includes(match));
|
|
106
109
|
reporter.log(`\nFound ${plural(resolveMapEntries.length, 'package')} matching "${bold(match)}":\n`, bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)));
|
|
107
|
-
return resolveMapEntries.map((entry) => entry.path);
|
|
110
|
+
return new Map(resolveMapEntries.map((entry) => [entry.path, undefined]));
|
|
108
111
|
}
|
|
109
112
|
function sortExportKeys({ packageSettings = [] }) {
|
|
110
113
|
for (const settings of packageSettings) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;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,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAC7F,CAAC;IAEF,OAAO,IAAI,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,cAAc,CAAC,EAAE,eAAe,GAAG,EAAE,EAAmB;IAC/D,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE;QACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACrB,SAAS;SACV;QAED,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAmC,CAAC;QAErE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;aACzB,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CACvC,CAAC;KACH;AACH,CAAC","sourcesContent":["import type { Context } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, GeneratedConfig, PackageJsonExportsObject } from '@ms-cloudpack/config-types';\nimport type { PackageImporterContext } from '@ms-cloudpack/bundler-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server/apis';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\nimport { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n appPath: string;\n config: CloudpackConfig;\n autoDispose: AutoDispose;\n reporter: TaskReporter;\n telemetryClient: TelemetryClient;\n}): Promise<InitSummary> {\n const { options, appPath, config, reporter, autoDispose, telemetryClient } = parameters;\n\n // Don't allow --check and --reset together.\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const ctx: Context = await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n });\n autoDispose(ctx);\n const resolveMap = ctx.session.resolveMap;\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n const summaryData = new InitSummaryData();\n\n await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n\n // Start with the app path or requested matches\n enqueuePaths(getInitialPaths({ appPath, match: options.match, resolveMap, reporter }));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n continue;\n }\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n visitedSet.add(packagePath);\n pending++;\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n shouldForce,\n initOptions: options,\n summaryData,\n ctx,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size && !options.match) {\n // If there are paths that need to be rebuilt, add them to the refresh set so that on re-enqueuing\n // we pass the `shouldRerun` flag through\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n reject(error);\n });\n }\n }\n });\n\n const summary = summaryData.summarize();\n\n if (!options.check && summary.totalChanges && config.generated.packageSettings?.length) {\n sortExportKeys(config.generated);\n\n await writeGeneratedConfig(config.generated, appPath);\n }\n\n return summary;\n}\n\n/**\n * Get initial package paths to process: either the app path, or packages matching `match` in the init options.\n */\nfunction getInitialPaths(params: {\n appPath: string;\n /** Only evaluate packages matching this string (from init options). */\n match: string | undefined;\n resolveMap: ResolveMap;\n reporter: TaskReporter;\n}): Map<string, PackageImporterContext | undefined> {\n const { appPath, match, resolveMap, reporter } = params;\n\n if (!match) {\n return new Map([[appPath, undefined]]);\n }\n\n // Find matching packages in the resolve map\n const resolveMapEntries = Object.values(resolveMap).filter((entry) => entry.name.includes(match));\n\n reporter.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching \"${bold(match)}\":\\n`,\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n\n return new Map(resolveMapEntries.map((entry) => [entry.path, undefined]));\n}\n\nfunction sortExportKeys({ packageSettings = [] }: GeneratedConfig) {\n for (const settings of packageSettings) {\n if (!settings.exports) {\n continue;\n }\n\n const unsortedExports = settings.exports as PackageJsonExportsObject;\n\n settings.exports = Object.fromEntries(\n Object.keys(unsortedExports)\n .sort()\n .map((k) => [k, unsortedExports[k]]),\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitOptions.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Defines the options for the \"init\" command.\n */\nexport interface InitOptions {\n /**\n * Whether to ignore existing overrides when determining all entries.\n */\n reset?: boolean;\n\n /**\n * Whether to fail on missing exports.\n */\n check?: boolean;\n\n /**\n * Only evaluate
|
|
1
|
+
{"version":3,"file":"InitOptions.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Defines the options for the \"init\" command.\n */\nexport interface InitOptions {\n /**\n * Whether to ignore existing overrides when determining all entries.\n */\n reset?: boolean;\n\n /**\n * Whether to fail on missing exports.\n */\n check?: boolean;\n\n /**\n * Only evaluate packages matching this string (e.g. `@ms-cloudpack/`).\n */\n match?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineProcess.inline.d.ts","sourceRoot":"","sources":["../../../../../src/commands/start/appServer/inlineScripts/defineProcess.inline.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// This file must NOT import other files, because they won't be resolved at runtime.
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
+
window.process ??= {};
|
|
4
|
+
window.process.env ??= {};
|
|
5
|
+
// Assign true to process.browser for packages like readable-stream
|
|
6
|
+
process.browser = true;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=defineProcess.inline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineProcess.inline.js","sourceRoot":"","sources":["../../../../../src/commands/start/appServer/inlineScripts/defineProcess.inline.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,8DAA8D;AAC9D,MAAM,CAAC,OAAO,KAAK,EAAS,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC;AAE1B,mEAAmE;AAClE,OAA2C,CAAC,OAAO,GAAG,IAAI,CAAC","sourcesContent":["// This file must NOT import other files, because they won't be resolved at runtime.\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nwindow.process ??= {} as any;\nwindow.process.env ??= {};\n\n// Assign true to process.browser for packages like readable-stream\n(process as unknown as { browser: boolean }).browser = true;\n"]}
|
|
@@ -5,7 +5,7 @@ import { dynamicImportExtension } from '../../../../utilities/dynamicImportExten
|
|
|
5
5
|
const currentPath = fileURLToPath(path.dirname(import.meta.url));
|
|
6
6
|
let inlineScripts;
|
|
7
7
|
// List of files that we will load on demand.
|
|
8
|
-
const inlineScriptFiles = ['errorHandler', 'getBrowserCacheRatio', 'getPageLoadTime'].map((file) => `${file}.inline${dynamicImportExtension}`);
|
|
8
|
+
const inlineScriptFiles = ['defineProcess', 'errorHandler', 'getBrowserCacheRatio', 'getPageLoadTime'].map((file) => `${file}.inline${dynamicImportExtension}`);
|
|
9
9
|
export async function getInlineScripts() {
|
|
10
10
|
if (!inlineScripts) {
|
|
11
11
|
inlineScripts = await Promise.all(inlineScriptFiles.map((filename) => fsPromises.readFile(path.join(currentPath, filename), 'utf-8')));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInlineScripts.js","sourceRoot":"","sources":["../../../../../src/commands/start/appServer/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAEzF,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,IAAI,aAAmC,CAAC;AAExC,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"getInlineScripts.js","sourceRoot":"","sources":["../../../../../src/commands/start/appServer/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAEzF,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,IAAI,aAAmC,CAAC;AAExC,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,CAAC,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAC,GAAG,CACxG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,UAAU,sBAAsB,EAAE,CACpD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,aAAa,EAAE;QAClB,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CACpG,CAAC;KACH;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import fsPromises from 'fs/promises';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { dynamicImportExtension } from '../../../../utilities/dynamicImportExtension.js';\n\nconst currentPath = fileURLToPath(path.dirname(import.meta.url));\n\nlet inlineScripts: string[] | undefined;\n\n// List of files that we will load on demand.\nconst inlineScriptFiles = ['defineProcess', 'errorHandler', 'getBrowserCacheRatio', 'getPageLoadTime'].map(\n (file) => `${file}.inline${dynamicImportExtension}`,\n);\n\nexport async function getInlineScripts() {\n if (!inlineScripts) {\n inlineScripts = await Promise.all(\n inlineScriptFiles.map((filename) => fsPromises.readFile(path.join(currentPath, filename), 'utf-8')),\n );\n }\n\n return inlineScripts;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.27.
|
|
14
|
-
"@ms-cloudpack/config": "^0.17.
|
|
15
|
-
"@ms-cloudpack/config-types": "^0.1.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.27.4",
|
|
14
|
+
"@ms-cloudpack/config": "^0.17.2",
|
|
15
|
+
"@ms-cloudpack/config-types": "^0.1.1",
|
|
16
16
|
"@ms-cloudpack/create-express-app": "^1.3.12",
|
|
17
|
-
"@ms-cloudpack/json-utilities": "^0.1.
|
|
18
|
-
"@ms-cloudpack/overlay": "^0.16.
|
|
19
|
-
"@ms-cloudpack/package-hashes": "^0.2.
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^5.
|
|
17
|
+
"@ms-cloudpack/json-utilities": "^0.1.2",
|
|
18
|
+
"@ms-cloudpack/overlay": "^0.16.27",
|
|
19
|
+
"@ms-cloudpack/package-hashes": "^0.2.3",
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^5.6.0",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.1.1",
|
|
22
|
-
"@ms-cloudpack/task-reporter": "^0.10.
|
|
23
|
-
"@ms-cloudpack/telemetry": "^0.4.
|
|
22
|
+
"@ms-cloudpack/task-reporter": "^0.10.2",
|
|
23
|
+
"@ms-cloudpack/telemetry": "^0.4.4",
|
|
24
|
+
"@yarnpkg/lockfile": "^1.1.0",
|
|
24
25
|
"commander": "^11.1.0",
|
|
25
26
|
"cross-spawn": "^7.0.3",
|
|
26
27
|
"fast-glob": "^3.2.12",
|
|
@@ -28,7 +29,8 @@
|
|
|
28
29
|
"jsdom": "^22.0.0",
|
|
29
30
|
"open": "^9.0.0",
|
|
30
31
|
"prompts": "^2.4.2",
|
|
31
|
-
"semver": "^7.3.7"
|
|
32
|
+
"semver": "^7.3.7",
|
|
33
|
+
"workspace-tools": "^0.36.3"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@ms-cloudpack/bundler-types": "*",
|