cabloy 5.1.219 → 5.1.220
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/.cabloy-version +1 -1
- package/.github/workflows/create-cabloy.yml +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/repo-docs/fullstack/quickstart.md +3 -3
- package/repo-docs/reference/repo-scripts.md +12 -0
- package/scripts/generateOpenapiIsolated.test.ts +25 -0
- package/scripts/generateOpenapiIsolated.ts +28 -11
- package/scripts/runIsolatedTest.test.ts +157 -45
- package/scripts/runIsolatedTest.ts +30 -6
- package/scripts/strictGenerationStartup.test.ts +212 -0
- package/vona/packages-cli/cli/package.json +1 -1
- package/vona/packages-cli/cli-set-api/package.json +1 -1
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/packages-vona/vona-core/package.json +1 -1
- package/vona/packages-vona/vona-core/src/lib/bean/beanBase.ts +4 -0
- package/vona/packages-vona/vona-core/src/lib/core/asyncLocalStorage.ts +84 -12
- package/vona/packages-vona/vona-core/src/lib/core/index.ts +14 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/appLogger.ts +11 -3
- package/vona/packages-vona/vona-core/src/lib/core/logger/diagnosticLogger.test.ts +146 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/diagnosticLogger.ts +138 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/index.ts +1 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/utils.ts +25 -5
- package/vona/packages-vona/vona-core/src/lib/core/requestBoundary.ts +89 -0
- package/vona/packages-vona/vona-core/src/lib/core/testFreshness.test.ts +379 -0
- package/vona/packages-vona/vona-core/src/lib/core/testFreshness.ts +238 -0
- package/vona/packages-vona/vona-core/src/lib/framework/start.test.ts +4 -3
- package/vona/packages-vona/vona-core/src/lib/framework/start.ts +2 -0
- package/vona/packages-vona/vona-mock/package.json +1 -1
- package/vona/pnpm-lock.yaml +154 -125
- package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-executor/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/bean/bean.executor.ts +111 -60
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/service/executor.ts +6 -6
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/types/executor.ts +13 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/lib/jwtClientLogging.test.ts +182 -0
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/service/jwtClient.ts +2 -8
- package/vona/src/suite-vendor/a-vona/modules/a-logger/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/aopMethod.log.ts +4 -1
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/bean.logger.ts +9 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/middlewareSystem.httpLog.ts +27 -14
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/lib/redactHttpLog.test.ts +207 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/lib/redactHttpLog.ts +30 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/test/middlewareSystem.httpLog.test.ts +33 -1
- package/vona/src/suite-vendor/a-vona/modules/a-startup/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-startup/src/service/startup.ts +6 -0
- package/vona/src/suite-vendor/a-vona/modules/a-startup/test/devSeed.test.ts +2 -2
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/bean/bean.telemetry.ts +8 -1
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/bean/middlewareSystem.trace.ts +9 -14
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/lib/spanDiagnostics.ts +70 -0
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/service/telemetry.ts +37 -23
- package/vona/src/suite-vendor/a-vona/modules/a-version/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-version/src/service/database.ts +31 -4
- package/vona/src/suite-vendor/a-vona/package.json +2 -2
- package/zova/packages-cli/cli/package.json +2 -2
- package/zova/packages-cli/cli-set-front/package.json +1 -1
- package/zova/packages-cli/cli-set-front/src/lib/bean/cli.bin.buildRest.ts +11 -101
- package/zova/packages-cli/cli-set-front/src/lib/common/restDependencies.ts +78 -0
- package/zova/packages-cli/cli-set-front/src/lib/common/restDependencyVersions.ts +231 -0
- package/zova/packages-cli/cli-set-front/test/restDependencies.test.ts +431 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { describe, it } from 'node:test';
|
|
6
|
+
|
|
7
|
+
import { extractRestDependencies } from '../src/lib/common/restDependencies.ts';
|
|
8
|
+
import { extractRestDependencyVersions } from '../src/lib/common/restDependencyVersions.ts';
|
|
9
|
+
|
|
10
|
+
const sideEffectModules = [
|
|
11
|
+
'zova-module-a-fetch',
|
|
12
|
+
'zova-module-a-app',
|
|
13
|
+
'zova-module-a-logger',
|
|
14
|
+
'zova-module-a-meta',
|
|
15
|
+
'zova-module-a-ssrhmr',
|
|
16
|
+
'zova-module-a-zod',
|
|
17
|
+
'zova-module-a-zova',
|
|
18
|
+
'zova-module-a-rbac',
|
|
19
|
+
'zova-module-pay-paypal',
|
|
20
|
+
'zova-module-pay-stripe',
|
|
21
|
+
'zova-module-a-behaviors',
|
|
22
|
+
'zova-module-a-routerstack',
|
|
23
|
+
'zova-module-a-ssrserver',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
async function withFixture(callback: (projectPath: string) => Promise<void>): Promise<void> {
|
|
27
|
+
const projectPath = await mkdtemp(path.join(os.tmpdir(), 'rest-dependency-'));
|
|
28
|
+
try {
|
|
29
|
+
await callback(projectPath);
|
|
30
|
+
} finally {
|
|
31
|
+
await rm(projectPath, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function writeFixtureFile(
|
|
36
|
+
projectPath: string,
|
|
37
|
+
relativePath: string,
|
|
38
|
+
content: string,
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
const filePath = path.join(projectPath, relativePath);
|
|
41
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
42
|
+
await writeFile(filePath, content);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function writePackage(
|
|
46
|
+
projectPath: string,
|
|
47
|
+
relativePath: string,
|
|
48
|
+
packageJson: Record<string, unknown>,
|
|
49
|
+
): Promise<void> {
|
|
50
|
+
await writeFixtureFile(
|
|
51
|
+
projectPath,
|
|
52
|
+
path.join(relativePath, 'package.json'),
|
|
53
|
+
JSON.stringify(packageJson),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function writeLockfile(projectPath: string, content: string): Promise<void> {
|
|
58
|
+
await writeFixtureFile(projectPath, 'pnpm-lock.yaml', content);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe('extractRestDependencies', () => {
|
|
62
|
+
it('retains consecutive side-effect imports before named imports', () => {
|
|
63
|
+
const content = `${sideEffectModules.map(name => `import "${name}";`).join('\n')}
|
|
64
|
+
import type { Schema } from 'zod';
|
|
65
|
+
//#region bundled declarations
|
|
66
|
+
export declare const schema: Schema;
|
|
67
|
+
`;
|
|
68
|
+
assert.deepEqual(extractRestDependencies(content), [...sideEffectModules, 'zod'].sort());
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('collects imports and re-exports without relying on region comments', () => {
|
|
72
|
+
assert.deepEqual(
|
|
73
|
+
extractRestDependencies(`
|
|
74
|
+
import type {
|
|
75
|
+
Foo,
|
|
76
|
+
} from '@scope/types/subpath';
|
|
77
|
+
import Default from "plain-package";
|
|
78
|
+
export * from '@scope/exported';
|
|
79
|
+
export type { Bar } from 'exported/subpath';
|
|
80
|
+
export { Default };
|
|
81
|
+
`),
|
|
82
|
+
['@scope/exported', '@scope/types', 'exported', 'plain-package'],
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('collects nested import types and external import assignments after region comments', () => {
|
|
87
|
+
assert.deepEqual(
|
|
88
|
+
extractRestDependencies(`
|
|
89
|
+
//#region generated
|
|
90
|
+
import Legacy = require('legacy/subpath');
|
|
91
|
+
export type Options = {
|
|
92
|
+
value: import('@scope/types/options').Options;
|
|
93
|
+
factory: typeof import('factory');
|
|
94
|
+
};
|
|
95
|
+
export * from 'after-region';
|
|
96
|
+
`),
|
|
97
|
+
['@scope/types', 'after-region', 'factory', 'legacy'],
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('does not treat module declarations or import-like text as dependencies', () => {
|
|
102
|
+
assert.deepEqual(
|
|
103
|
+
extractRestDependencies(`
|
|
104
|
+
// import 'comment-only';
|
|
105
|
+
/** export * from 'comment-export'; */
|
|
106
|
+
declare const text: "import 'string-only'";
|
|
107
|
+
declare module 'bundled-business-module' {
|
|
108
|
+
import type { External } from 'real-dependency';
|
|
109
|
+
export type Value = import('@scope/nested').Value;
|
|
110
|
+
}
|
|
111
|
+
declare module 'augmentation-target' {
|
|
112
|
+
interface Options { enabled: boolean }
|
|
113
|
+
}
|
|
114
|
+
`),
|
|
115
|
+
['@scope/nested', 'real-dependency'],
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('ignores local paths, builtins, internal aliases and virtual identifiers', () => {
|
|
120
|
+
assert.deepEqual(
|
|
121
|
+
extractRestDependencies(`
|
|
122
|
+
import './local.js';
|
|
123
|
+
import '../parent.js';
|
|
124
|
+
import '/absolute/file.js';
|
|
125
|
+
import 'C:/absolute/file.js';
|
|
126
|
+
import 'node:fs/promises';
|
|
127
|
+
import 'fs/promises';
|
|
128
|
+
import 'path';
|
|
129
|
+
import '#internal';
|
|
130
|
+
import 'virtual:generated';
|
|
131
|
+
import '\\0virtual';
|
|
132
|
+
import 'file:///local/file.js';
|
|
133
|
+
import 'https://example.invalid/module.js';
|
|
134
|
+
`),
|
|
135
|
+
[],
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('deduplicates package roots and sorts deterministically', () => {
|
|
140
|
+
assert.deepEqual(
|
|
141
|
+
extractRestDependencies(`
|
|
142
|
+
import 'zod';
|
|
143
|
+
export * from 'zod/v4';
|
|
144
|
+
import '@scope/pkg';
|
|
145
|
+
export type Value = import('@scope/pkg/subpath').Value;
|
|
146
|
+
import 'alpha/subpath';
|
|
147
|
+
`),
|
|
148
|
+
['@scope/pkg', 'alpha', 'zod'],
|
|
149
|
+
);
|
|
150
|
+
assert.deepEqual(extractRestDependencies(''), []);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('rejects malformed declarations instead of returning partial dependencies', () => {
|
|
154
|
+
assert.throws(
|
|
155
|
+
() => extractRestDependencies("import 'valid-package';\nexport type Broken = {"),
|
|
156
|
+
/Invalid REST declaration at index\.d\.mts:2:23: .+/,
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('rejects path and type reference directives', () => {
|
|
161
|
+
for (const [kind, target] of [
|
|
162
|
+
['path', './external.d.ts'],
|
|
163
|
+
['types', 'external-types'],
|
|
164
|
+
]) {
|
|
165
|
+
assert.throws(
|
|
166
|
+
() =>
|
|
167
|
+
extractRestDependencies(`/// <reference ${kind}="${target}" />\nimport 'valid-package';`),
|
|
168
|
+
{
|
|
169
|
+
message:
|
|
170
|
+
`Unsupported REST declaration reference directive: ${kind} ${JSON.stringify(target)}. ` +
|
|
171
|
+
'The current REST bundling workflow does not support this directive.',
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('does not treat compiler lib references as package dependencies', () => {
|
|
178
|
+
assert.deepEqual(
|
|
179
|
+
extractRestDependencies(`
|
|
180
|
+
/// <reference lib="esnext" />
|
|
181
|
+
/// <reference no-default-lib="true" />
|
|
182
|
+
import 'real-package';
|
|
183
|
+
`),
|
|
184
|
+
['real-package'],
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('rejects empty and incomplete scoped package references', () => {
|
|
189
|
+
for (const specifier of ['', '@scope', '@scope/', '@/package', '@']) {
|
|
190
|
+
assert.throws(
|
|
191
|
+
() => extractRestDependencies(`import '${specifier}';`),
|
|
192
|
+
/(?:Invalid|Unsupported) REST declaration package reference:/,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('rejects colon-containing package references that are not URL schemes', () => {
|
|
198
|
+
for (const specifier of ['@scope/package:invalid', 'package/subpath:invalid']) {
|
|
199
|
+
assert.throws(
|
|
200
|
+
() => extractRestDependencies(`export * from '${specifier}';`),
|
|
201
|
+
/Unsupported REST declaration package reference:/,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('rejects nonliteral import types and non-string module specifiers', () => {
|
|
207
|
+
assert.throws(
|
|
208
|
+
() => extractRestDependencies('export type Value = import(PackageName).Value;'),
|
|
209
|
+
/Unsupported REST declaration import type/,
|
|
210
|
+
);
|
|
211
|
+
assert.throws(
|
|
212
|
+
() => extractRestDependencies('export type Value = import(42).Value;'),
|
|
213
|
+
/Unsupported REST declaration module specifier/,
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('rejects dynamic import calls instead of silently omitting their dependencies', () => {
|
|
218
|
+
assert.throws(
|
|
219
|
+
() => extractRestDependencies("const value = import('runtime-package');"),
|
|
220
|
+
/Unsupported REST declaration dynamic import/,
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('retains external import assignments and ignores internal import aliases', () => {
|
|
225
|
+
assert.deepEqual(
|
|
226
|
+
extractRestDependencies(`
|
|
227
|
+
import Scoped = require('@scope/legacy/subpath');
|
|
228
|
+
import Local = require('./local.js');
|
|
229
|
+
import Builtin = require('node:fs');
|
|
230
|
+
import Internal = require('#internal');
|
|
231
|
+
import Remote = require('https://example.invalid/module.js');
|
|
232
|
+
declare namespace Existing { interface Value {} }
|
|
233
|
+
import Alias = Existing.Value;
|
|
234
|
+
`),
|
|
235
|
+
['@scope/legacy'],
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe('extractRestDependencyVersions', () => {
|
|
241
|
+
it('uses the root importer range when the dependency is declared there', async () => {
|
|
242
|
+
await withFixture(async projectPath => {
|
|
243
|
+
await writeLockfile(
|
|
244
|
+
projectPath,
|
|
245
|
+
`lockfileVersion: '9.0'
|
|
246
|
+
importers:
|
|
247
|
+
.:
|
|
248
|
+
dependencies:
|
|
249
|
+
root-package:
|
|
250
|
+
specifier: ^1.2.3
|
|
251
|
+
version: 1.2.3
|
|
252
|
+
`,
|
|
253
|
+
);
|
|
254
|
+
assert.deepEqual(await extractRestDependencyVersions(projectPath, ['root-package']), {
|
|
255
|
+
'root-package': '^1.2.3',
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('resolves a dependency from its owning module importer', async () => {
|
|
261
|
+
await withFixture(async projectPath => {
|
|
262
|
+
const moduleRoot = 'zova/src/suite/example/modules/example-one';
|
|
263
|
+
await writeLockfile(
|
|
264
|
+
projectPath,
|
|
265
|
+
`lockfileVersion: '9.0'
|
|
266
|
+
importers:
|
|
267
|
+
.:
|
|
268
|
+
dependencies: {}
|
|
269
|
+
${moduleRoot}:
|
|
270
|
+
dependencies:
|
|
271
|
+
owned-package:
|
|
272
|
+
specifier: ^2.0.4
|
|
273
|
+
version: 2.0.4
|
|
274
|
+
`,
|
|
275
|
+
);
|
|
276
|
+
assert.deepEqual(
|
|
277
|
+
await extractRestDependencyVersions(projectPath, ['owned-package'], [moduleRoot]),
|
|
278
|
+
{ 'owned-package': '^2.0.4' },
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('falls back to an installed module dependency when the lock importer is absent', async () => {
|
|
284
|
+
await withFixture(async projectPath => {
|
|
285
|
+
const moduleRoot = 'zova/src/module/example-one';
|
|
286
|
+
await writePackage(projectPath, moduleRoot, {
|
|
287
|
+
name: 'zova-module-example-one',
|
|
288
|
+
dependencies: { 'installed-package': '^3.1.0' },
|
|
289
|
+
});
|
|
290
|
+
await writePackage(projectPath, path.join(moduleRoot, 'node_modules', 'installed-package'), {
|
|
291
|
+
name: 'installed-package',
|
|
292
|
+
version: '3.1.7',
|
|
293
|
+
});
|
|
294
|
+
await writeLockfile(
|
|
295
|
+
projectPath,
|
|
296
|
+
"lockfileVersion: '9.0'\nimporters:\n .:\n dependencies: {}\n",
|
|
297
|
+
);
|
|
298
|
+
assert.deepEqual(
|
|
299
|
+
await extractRestDependencyVersions(projectPath, ['installed-package'], [moduleRoot]),
|
|
300
|
+
{ 'installed-package': '^3.1.7' },
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('rejects conflicting module dependency versions', async () => {
|
|
306
|
+
await withFixture(async projectPath => {
|
|
307
|
+
const firstModule = 'zova/src/module/first';
|
|
308
|
+
const secondModule = 'zova/src/module/second';
|
|
309
|
+
await writeLockfile(
|
|
310
|
+
projectPath,
|
|
311
|
+
`lockfileVersion: '9.0'
|
|
312
|
+
importers:
|
|
313
|
+
.:
|
|
314
|
+
dependencies: {}
|
|
315
|
+
${firstModule}:
|
|
316
|
+
dependencies:
|
|
317
|
+
conflicting-package:
|
|
318
|
+
specifier: ^1.0.0
|
|
319
|
+
version: 1.0.0
|
|
320
|
+
${secondModule}:
|
|
321
|
+
dependencies:
|
|
322
|
+
conflicting-package:
|
|
323
|
+
specifier: ^2.0.0
|
|
324
|
+
version: 2.0.0
|
|
325
|
+
`,
|
|
326
|
+
);
|
|
327
|
+
await assert.rejects(
|
|
328
|
+
extractRestDependencyVersions(
|
|
329
|
+
projectPath,
|
|
330
|
+
['conflicting-package'],
|
|
331
|
+
[firstModule, secondModule],
|
|
332
|
+
),
|
|
333
|
+
/Conflicting REST dependency versions for conflicting-package/,
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('preserves npm aliases and strips peer suffixes from locked versions', async () => {
|
|
339
|
+
await withFixture(async projectPath => {
|
|
340
|
+
await writeLockfile(
|
|
341
|
+
projectPath,
|
|
342
|
+
`
|
|
343
|
+
importers:
|
|
344
|
+
.:
|
|
345
|
+
dependencies:
|
|
346
|
+
zod:
|
|
347
|
+
specifier: npm:@cabloy/zod@4.3.8
|
|
348
|
+
version: '@cabloy/zod@4.3.8'
|
|
349
|
+
devDependencies:
|
|
350
|
+
peer-package:
|
|
351
|
+
specifier: ^1.2.0
|
|
352
|
+
version: 1.2.3(vue@3.5.42)
|
|
353
|
+
optionalDependencies:
|
|
354
|
+
optional-package:
|
|
355
|
+
specifier: ^2.0.0
|
|
356
|
+
version: 2.0.1
|
|
357
|
+
`,
|
|
358
|
+
);
|
|
359
|
+
assert.deepEqual(
|
|
360
|
+
await extractRestDependencyVersions(projectPath, [
|
|
361
|
+
'zod',
|
|
362
|
+
'peer-package',
|
|
363
|
+
'optional-package',
|
|
364
|
+
]),
|
|
365
|
+
{ 'zod': 'npm:@cabloy/zod@4.3.8', 'peer-package': '^1.2.3', 'optional-package': '^2.0.1' },
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('accepts matching module candidates with absolute and relative module roots', async () => {
|
|
371
|
+
await withFixture(async projectPath => {
|
|
372
|
+
const firstModule = 'src/module/first';
|
|
373
|
+
const secondModule = 'src/module/second';
|
|
374
|
+
await writeLockfile(
|
|
375
|
+
projectPath,
|
|
376
|
+
`
|
|
377
|
+
importers:
|
|
378
|
+
${firstModule}:
|
|
379
|
+
dependencies:
|
|
380
|
+
shared-package:
|
|
381
|
+
version: 1.2.3(vue@3.5.42)
|
|
382
|
+
${secondModule}:
|
|
383
|
+
dependencies:
|
|
384
|
+
shared-package:
|
|
385
|
+
version: 1.2.3(vue@3.5.43)
|
|
386
|
+
`,
|
|
387
|
+
);
|
|
388
|
+
assert.deepEqual(
|
|
389
|
+
await extractRestDependencyVersions(
|
|
390
|
+
projectPath,
|
|
391
|
+
['shared-package'],
|
|
392
|
+
[firstModule, path.join(projectPath, secondModule)],
|
|
393
|
+
),
|
|
394
|
+
{ 'shared-package': '^1.2.3' },
|
|
395
|
+
);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('uses an installed root package for a linked dependency', async () => {
|
|
400
|
+
await withFixture(async projectPath => {
|
|
401
|
+
await writeLockfile(
|
|
402
|
+
projectPath,
|
|
403
|
+
`
|
|
404
|
+
importers:
|
|
405
|
+
.:
|
|
406
|
+
dependencies:
|
|
407
|
+
linked-package:
|
|
408
|
+
specifier: workspace:*
|
|
409
|
+
version: link:packages/linked-package
|
|
410
|
+
`,
|
|
411
|
+
);
|
|
412
|
+
await writePackage(projectPath, 'node_modules/linked-package', { version: '5.1.2' });
|
|
413
|
+
assert.deepEqual(await extractRestDependencyVersions(projectPath, ['linked-package']), {
|
|
414
|
+
'linked-package': '^5.1.2',
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('rejects dependencies without a resolvable version', async () => {
|
|
420
|
+
await withFixture(async projectPath => {
|
|
421
|
+
await writeLockfile(
|
|
422
|
+
projectPath,
|
|
423
|
+
"lockfileVersion: '9.0'\nimporters:\n .:\n dependencies: {}\n",
|
|
424
|
+
);
|
|
425
|
+
await assert.rejects(
|
|
426
|
+
extractRestDependencyVersions(projectPath, ['missing-package']),
|
|
427
|
+
/Unable to resolve REST dependency version for missing-package/,
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
});
|