isolate-package 1.27.0 → 1.28.1
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/README.md +20 -420
- package/dist/index.d.mts +13 -5
- package/dist/index.mjs +21 -2
- package/dist/index.mjs.map +1 -0
- package/dist/{isolate-B11ztsrI.mjs → isolate-D-Qd5BJJ.mjs} +114 -25
- package/dist/isolate-D-Qd5BJJ.mjs.map +1 -0
- package/dist/isolate-bin.mjs +1 -1
- package/dist/isolate-bin.mjs.map +1 -1
- package/package.json +37 -32
- package/src/get-internal-package-names.test.ts +213 -0
- package/src/get-internal-package-names.ts +38 -0
- package/src/index.ts +3 -5
- package/src/isolate-bin.ts +1 -1
- package/src/isolate.ts +21 -31
- package/src/lib/cli.test.ts +3 -3
- package/src/lib/cli.ts +4 -4
- package/src/lib/config.test.ts +163 -0
- package/src/lib/config.ts +134 -8
- package/src/lib/lockfile/helpers/generate-pnpm-lockfile.ts +6 -6
- package/src/lib/lockfile/helpers/pnpm-map-importer.ts +5 -5
- package/src/lib/lockfile/process-lockfile.ts +3 -3
- package/src/lib/manifest/adapt-target-package-manifest.ts +2 -2
- package/src/lib/manifest/helpers/adapt-internal-package-manifests.ts +3 -3
- package/src/lib/manifest/helpers/adapt-manifest-internal-deps.ts +2 -2
- package/src/lib/manifest/helpers/adopt-pnpm-fields-from-root.test.ts +1 -1
- package/src/lib/manifest/helpers/adopt-pnpm-fields-from-root.ts +2 -2
- package/src/lib/manifest/helpers/patch-internal-entries.ts +2 -2
- package/src/lib/manifest/helpers/resolve-catalog-dependencies.ts +3 -3
- package/src/lib/manifest/io.ts +2 -2
- package/src/lib/manifest/validate-manifest.test.ts +10 -10
- package/src/lib/manifest/validate-manifest.ts +1 -1
- package/src/lib/output/unpack-dependencies.ts +4 -4
- package/src/lib/package-manager/helpers/infer-from-files.ts +1 -1
- package/src/lib/package-manager/helpers/infer-from-manifest.ts +3 -3
- package/src/lib/package-manager/index.ts +2 -2
- package/src/lib/patches/copy-patches.test.ts +7 -7
- package/src/lib/patches/copy-patches.ts +5 -5
- package/src/lib/registry/create-packages-registry.ts +12 -14
- package/src/lib/registry/helpers/find-packages-globs.ts +7 -7
- package/src/lib/registry/list-internal-packages.test.ts +291 -0
- package/src/lib/registry/list-internal-packages.ts +70 -18
- package/src/lib/utils/filter-object-undefined.test.ts +1 -1
- package/src/lib/utils/filter-object-undefined.ts +1 -1
- package/src/lib/utils/filter-patched-dependencies.ts +2 -2
- package/src/lib/utils/json.ts +4 -4
- package/src/lib/utils/pack.ts +3 -3
- package/src/lib/utils/yaml.ts +1 -1
- package/dist/isolate-B11ztsrI.mjs.map +0 -1
- package/docs/firebase.md +0 -144
package/src/lib/config.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
1
2
|
import fs from "fs-extra";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
3
5
|
import { isEmpty } from "remeda";
|
|
4
6
|
import { type LogLevel, setLogLevel, useLogger } from "./logger";
|
|
5
7
|
import { inspectValue, readTypedJsonSync } from "./utils";
|
|
@@ -37,19 +39,126 @@ const configDefaults: IsolateConfigResolved = {
|
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
const validConfigKeys = Object.keys(configDefaults);
|
|
40
|
-
const
|
|
42
|
+
const CONFIG_FILE_NAME_TS = "isolate.config.ts";
|
|
43
|
+
const CONFIG_FILE_NAME_JS = "isolate.config.js";
|
|
44
|
+
const CONFIG_FILE_NAME_JSON = "isolate.config.json";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Load a JS or TS config file by spawning a Node subprocess. For TS files,
|
|
48
|
+
* --experimental-strip-types is added so Node can handle TypeScript natively.
|
|
49
|
+
* This keeps the function synchronous while allowing us to import the module.
|
|
50
|
+
*/
|
|
51
|
+
const CONFIG_JSON_DELIMITER = "__ISOLATE_CONFIG_JSON__";
|
|
52
|
+
|
|
53
|
+
function loadModuleConfig(filePath: string): IsolateConfig {
|
|
54
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
55
|
+
const isTypeScript = filePath.endsWith(".ts");
|
|
56
|
+
const script = `import(process.argv[1])
|
|
57
|
+
.then(m => {
|
|
58
|
+
if (m.default === undefined) {
|
|
59
|
+
process.stderr.write("Config file has no default export");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
process.stdout.write("${CONFIG_JSON_DELIMITER}" + JSON.stringify(m.default) + "${CONFIG_JSON_DELIMITER}");
|
|
63
|
+
})
|
|
64
|
+
.catch(err => {
|
|
65
|
+
process.stderr.write(String(err));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
})`;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const result = execFileSync(
|
|
71
|
+
process.execPath,
|
|
72
|
+
[
|
|
73
|
+
...(isTypeScript ? ["--experimental-strip-types"] : []),
|
|
74
|
+
"--no-warnings",
|
|
75
|
+
"--input-type=module",
|
|
76
|
+
"-e",
|
|
77
|
+
script,
|
|
78
|
+
fileUrl,
|
|
79
|
+
],
|
|
80
|
+
{ encoding: "utf8" },
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const jsonMatch = result.split(CONFIG_JSON_DELIMITER)[1];
|
|
84
|
+
|
|
85
|
+
if (jsonMatch === undefined) {
|
|
86
|
+
throw new Error("Failed to extract config JSON from subprocess output");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const parsed = JSON.parse(jsonMatch);
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
typeof parsed !== "object" ||
|
|
93
|
+
parsed === null ||
|
|
94
|
+
Array.isArray(parsed)
|
|
95
|
+
) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Expected default export to be an object, got ${typeof parsed}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return parsed;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const stderr =
|
|
104
|
+
error instanceof Error && "stderr" in error
|
|
105
|
+
? String(error.stderr).trim()
|
|
106
|
+
: "";
|
|
107
|
+
const detail = stderr || (error instanceof Error ? error.message : "");
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Failed to load config from ${filePath}${detail ? `: ${detail}` : ""}`,
|
|
110
|
+
{ cause: error },
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
41
114
|
|
|
42
115
|
export function loadConfigFromFile(): IsolateConfig {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
116
|
+
const log = useLogger();
|
|
117
|
+
const cwd = process.cwd();
|
|
118
|
+
const tsConfigPath = path.join(cwd, CONFIG_FILE_NAME_TS);
|
|
119
|
+
const jsConfigPath = path.join(cwd, CONFIG_FILE_NAME_JS);
|
|
120
|
+
const jsonConfigPath = path.join(cwd, CONFIG_FILE_NAME_JSON);
|
|
121
|
+
|
|
122
|
+
const tsExists = fs.existsSync(tsConfigPath);
|
|
123
|
+
const jsExists = fs.existsSync(jsConfigPath);
|
|
124
|
+
const jsonExists = fs.existsSync(jsonConfigPath);
|
|
125
|
+
|
|
126
|
+
const existingFiles = [
|
|
127
|
+
tsExists && CONFIG_FILE_NAME_TS,
|
|
128
|
+
jsExists && CONFIG_FILE_NAME_JS,
|
|
129
|
+
jsonExists && CONFIG_FILE_NAME_JSON,
|
|
130
|
+
].filter(Boolean);
|
|
131
|
+
|
|
132
|
+
if (existingFiles.length > 1) {
|
|
133
|
+
log.warn(
|
|
134
|
+
`Found multiple config files: ${existingFiles.join(", ")}. Using ${existingFiles[0]}.`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (tsExists) {
|
|
139
|
+
return loadModuleConfig(tsConfigPath);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (jsExists) {
|
|
143
|
+
return loadModuleConfig(jsConfigPath);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (jsonExists) {
|
|
147
|
+
return readTypedJsonSync<IsolateConfig>(jsonConfigPath);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Helper for type-safe configuration in isolate.config.ts files. */
|
|
154
|
+
export function defineConfig(config: IsolateConfig): IsolateConfig {
|
|
155
|
+
return config;
|
|
47
156
|
}
|
|
48
157
|
|
|
49
158
|
function validateConfig(config: IsolateConfig) {
|
|
50
159
|
const log = useLogger();
|
|
51
160
|
const foreignKeys = Object.keys(config).filter(
|
|
52
|
-
(key) => !validConfigKeys.includes(key)
|
|
161
|
+
(key) => !validConfigKeys.includes(key),
|
|
53
162
|
);
|
|
54
163
|
|
|
55
164
|
if (!isEmpty(foreignKeys)) {
|
|
@@ -57,8 +166,25 @@ function validateConfig(config: IsolateConfig) {
|
|
|
57
166
|
}
|
|
58
167
|
}
|
|
59
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Resolve the target package directory and workspace root directory from the
|
|
171
|
+
* configuration. When targetPackagePath is set, the config is assumed to live
|
|
172
|
+
* at the workspace root. Otherwise it lives in the target package directory.
|
|
173
|
+
*/
|
|
174
|
+
export function resolveWorkspacePaths(config: IsolateConfigResolved) {
|
|
175
|
+
const targetPackageDir = config.targetPackagePath
|
|
176
|
+
? path.join(process.cwd(), config.targetPackagePath)
|
|
177
|
+
: process.cwd();
|
|
178
|
+
|
|
179
|
+
const workspaceRootDir = config.targetPackagePath
|
|
180
|
+
? process.cwd()
|
|
181
|
+
: path.join(targetPackageDir, config.workspaceRoot);
|
|
182
|
+
|
|
183
|
+
return { targetPackageDir, workspaceRootDir };
|
|
184
|
+
}
|
|
185
|
+
|
|
60
186
|
export function resolveConfig(
|
|
61
|
-
initialConfig?: IsolateConfig
|
|
187
|
+
initialConfig?: IsolateConfig,
|
|
62
188
|
): IsolateConfigResolved {
|
|
63
189
|
setLogLevel(process.env.DEBUG_ISOLATE_CONFIG ? "debug" : "info");
|
|
64
190
|
const log = useLogger();
|
|
@@ -68,7 +194,7 @@ export function resolveConfig(
|
|
|
68
194
|
if (initialConfig) {
|
|
69
195
|
log.debug(`Using user defined config:`, inspectValue(initialConfig));
|
|
70
196
|
} else {
|
|
71
|
-
log.debug(`Loaded config from
|
|
197
|
+
log.debug(`Loaded config from file`);
|
|
72
198
|
}
|
|
73
199
|
|
|
74
200
|
validateConfig(userConfig);
|
|
@@ -61,7 +61,7 @@ export async function generatePnpmLockfile({
|
|
|
61
61
|
: workspaceRootDir,
|
|
62
62
|
{
|
|
63
63
|
ignoreIncompatible: false,
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
65
|
)
|
|
66
66
|
: await readWantedLockfile_v8(
|
|
67
67
|
isRush
|
|
@@ -69,7 +69,7 @@ export async function generatePnpmLockfile({
|
|
|
69
69
|
: workspaceRootDir,
|
|
70
70
|
{
|
|
71
71
|
ignoreIncompatible: false,
|
|
72
|
-
}
|
|
72
|
+
},
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
assert(lockfile, `No input lockfile found at ${workspaceRootDir}`);
|
|
@@ -84,7 +84,7 @@ export async function generatePnpmLockfile({
|
|
|
84
84
|
assert(pkg, `Package ${name} not found in packages registry`);
|
|
85
85
|
|
|
86
86
|
return [name, pkg.rootRelativeDir];
|
|
87
|
-
})
|
|
87
|
+
}),
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
const relevantImporterIds = [
|
|
@@ -115,12 +115,12 @@ export async function generatePnpmLockfile({
|
|
|
115
115
|
* only for parsing.
|
|
116
116
|
*/
|
|
117
117
|
const relevantImporterIdsWithPrefix = relevantImporterIds.map((x) =>
|
|
118
|
-
isRush ? `../../${x}` : x
|
|
118
|
+
isRush ? `../../${x}` : x,
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
lockfile.importers = Object.fromEntries(
|
|
122
122
|
Object.entries(
|
|
123
|
-
pick(lockfile.importers, relevantImporterIdsWithPrefix)
|
|
123
|
+
pick(lockfile.importers, relevantImporterIdsWithPrefix),
|
|
124
124
|
).map(([prefixedImporterId, importer]) => {
|
|
125
125
|
const importerId = isRush
|
|
126
126
|
? prefixedImporterId.replace("../../", "")
|
|
@@ -147,7 +147,7 @@ export async function generatePnpmLockfile({
|
|
|
147
147
|
directoryByPackageName,
|
|
148
148
|
}),
|
|
149
149
|
];
|
|
150
|
-
})
|
|
150
|
+
}),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
log.debug("Pruning the lockfile");
|
|
@@ -14,14 +14,14 @@ export function pnpmMapImporter(
|
|
|
14
14
|
}: {
|
|
15
15
|
includeDevDependencies: boolean;
|
|
16
16
|
directoryByPackageName: { [packageName: string]: string };
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
18
|
): ProjectSnapshot {
|
|
19
19
|
return {
|
|
20
20
|
dependencies: dependencies
|
|
21
21
|
? pnpmMapDependenciesLinks(
|
|
22
22
|
importerPath,
|
|
23
23
|
dependencies,
|
|
24
|
-
directoryByPackageName
|
|
24
|
+
directoryByPackageName,
|
|
25
25
|
)
|
|
26
26
|
: undefined,
|
|
27
27
|
devDependencies:
|
|
@@ -29,7 +29,7 @@ export function pnpmMapImporter(
|
|
|
29
29
|
? pnpmMapDependenciesLinks(
|
|
30
30
|
importerPath,
|
|
31
31
|
devDependencies,
|
|
32
|
-
directoryByPackageName
|
|
32
|
+
directoryByPackageName,
|
|
33
33
|
)
|
|
34
34
|
: undefined,
|
|
35
35
|
...rest,
|
|
@@ -44,7 +44,7 @@ export function pnpmMapImporter(
|
|
|
44
44
|
function pnpmMapDependenciesLinks(
|
|
45
45
|
importerPath: string,
|
|
46
46
|
def: ResolvedDependencies,
|
|
47
|
-
directoryByPackageName: { [packageName: string]: string }
|
|
47
|
+
directoryByPackageName: { [packageName: string]: string },
|
|
48
48
|
): ResolvedDependencies {
|
|
49
49
|
return Object.fromEntries(
|
|
50
50
|
Object.entries(def).flatMap(([key, value]) => {
|
|
@@ -73,6 +73,6 @@ function pnpmMapDependenciesLinks(
|
|
|
73
73
|
: `link:./${relativePath}`;
|
|
74
74
|
|
|
75
75
|
return [[key, linkValue]];
|
|
76
|
-
})
|
|
76
|
+
}),
|
|
77
77
|
);
|
|
78
78
|
}
|
|
@@ -69,7 +69,7 @@ export async function processLockfile({
|
|
|
69
69
|
});
|
|
70
70
|
} else {
|
|
71
71
|
log.warn(
|
|
72
|
-
"Detected modern version of Yarn. Using NPM lockfile fallback."
|
|
72
|
+
"Detected modern version of Yarn. Using NPM lockfile fallback.",
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
await generateNpmLockfile({
|
|
@@ -98,7 +98,7 @@ export async function processLockfile({
|
|
|
98
98
|
}
|
|
99
99
|
case "bun": {
|
|
100
100
|
log.warn(
|
|
101
|
-
`Ouput lockfiles for Bun are not yet supported. Using NPM for output
|
|
101
|
+
`Ouput lockfiles for Bun are not yet supported. Using NPM for output`,
|
|
102
102
|
);
|
|
103
103
|
await generateNpmLockfile({
|
|
104
104
|
workspaceRootDir,
|
|
@@ -110,7 +110,7 @@ export async function processLockfile({
|
|
|
110
110
|
}
|
|
111
111
|
default:
|
|
112
112
|
log.warn(
|
|
113
|
-
`Unexpected package manager ${name as string}. Using NPM for output
|
|
113
|
+
`Unexpected package manager ${name as string}. Using NPM for output`,
|
|
114
114
|
);
|
|
115
115
|
await generateNpmLockfile({
|
|
116
116
|
workspaceRootDir,
|
|
@@ -46,7 +46,7 @@ export async function adaptTargetPackageManifest({
|
|
|
46
46
|
...inputManifest,
|
|
47
47
|
dependencies: await resolveCatalogDependencies(
|
|
48
48
|
inputManifest.dependencies,
|
|
49
|
-
workspaceRootDir
|
|
49
|
+
workspaceRootDir,
|
|
50
50
|
),
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ export async function adaptTargetPackageManifest({
|
|
|
59
59
|
*/
|
|
60
60
|
await adoptPnpmFieldsFromRoot(
|
|
61
61
|
manifestWithResolvedCatalogs,
|
|
62
|
-
workspaceRootDir
|
|
62
|
+
workspaceRootDir,
|
|
63
63
|
)
|
|
64
64
|
: /** For other package managers we replace the links to internal dependencies */
|
|
65
65
|
adaptManifestInternalDeps({
|
|
@@ -39,7 +39,7 @@ export async function adaptInternalPackageManifests({
|
|
|
39
39
|
...strippedManifest,
|
|
40
40
|
dependencies: await resolveCatalogDependencies(
|
|
41
41
|
strippedManifest.dependencies,
|
|
42
|
-
workspaceRootDir
|
|
42
|
+
workspaceRootDir,
|
|
43
43
|
),
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -59,8 +59,8 @@ export async function adaptInternalPackageManifests({
|
|
|
59
59
|
|
|
60
60
|
await writeManifest(
|
|
61
61
|
path.join(isolateDir, rootRelativeDir),
|
|
62
|
-
outputManifest
|
|
62
|
+
outputManifest,
|
|
63
63
|
);
|
|
64
|
-
})
|
|
64
|
+
}),
|
|
65
65
|
);
|
|
66
66
|
}
|
|
@@ -23,14 +23,14 @@ export function adaptManifestInternalDeps({
|
|
|
23
23
|
? patchInternalEntries(
|
|
24
24
|
dependencies,
|
|
25
25
|
packagesRegistry,
|
|
26
|
-
parentRootRelativeDir
|
|
26
|
+
parentRootRelativeDir,
|
|
27
27
|
)
|
|
28
28
|
: undefined,
|
|
29
29
|
devDependencies: devDependencies
|
|
30
30
|
? patchInternalEntries(
|
|
31
31
|
devDependencies,
|
|
32
32
|
packagesRegistry,
|
|
33
|
-
parentRootRelativeDir
|
|
33
|
+
parentRootRelativeDir,
|
|
34
34
|
)
|
|
35
35
|
: undefined,
|
|
36
36
|
};
|
|
@@ -10,14 +10,14 @@ import { isRushWorkspace, readTypedJson } from "~/lib/utils";
|
|
|
10
10
|
*/
|
|
11
11
|
export async function adoptPnpmFieldsFromRoot(
|
|
12
12
|
targetPackageManifest: PackageManifest,
|
|
13
|
-
workspaceRootDir: string
|
|
13
|
+
workspaceRootDir: string,
|
|
14
14
|
): Promise<PackageManifest> {
|
|
15
15
|
if (isRushWorkspace(workspaceRootDir)) {
|
|
16
16
|
return targetPackageManifest;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const rootPackageManifest = await readTypedJson<ProjectManifest>(
|
|
20
|
-
path.join(workspaceRootDir, "package.json")
|
|
20
|
+
path.join(workspaceRootDir, "package.json"),
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
const { overrides, onlyBuiltDependencies, ignoredBuiltDependencies } =
|
|
@@ -6,7 +6,7 @@ import type { PackagesRegistry } from "../../types";
|
|
|
6
6
|
export function patchInternalEntries(
|
|
7
7
|
dependencies: Record<string, string>,
|
|
8
8
|
packagesRegistry: PackagesRegistry,
|
|
9
|
-
parentRootRelativeDir?: string
|
|
9
|
+
parentRootRelativeDir?: string,
|
|
10
10
|
) {
|
|
11
11
|
const log = useLogger();
|
|
12
12
|
const allWorkspacePackageNames = Object.keys(packagesRegistry);
|
|
@@ -37,6 +37,6 @@ export function patchInternalEntries(
|
|
|
37
37
|
} else {
|
|
38
38
|
return [key, value];
|
|
39
39
|
}
|
|
40
|
-
})
|
|
40
|
+
}),
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -14,7 +14,7 @@ import { readTypedJson } from "~/lib/utils";
|
|
|
14
14
|
*/
|
|
15
15
|
export async function resolveCatalogDependencies(
|
|
16
16
|
dependencies: Record<string, string> | undefined,
|
|
17
|
-
workspaceRootDir: string
|
|
17
|
+
workspaceRootDir: string,
|
|
18
18
|
): Promise<Record<string, string> | undefined> {
|
|
19
19
|
if (!dependencies) {
|
|
20
20
|
return undefined;
|
|
@@ -61,12 +61,12 @@ export async function resolveCatalogDependencies(
|
|
|
61
61
|
|
|
62
62
|
if (catalogVersion) {
|
|
63
63
|
log.debug(
|
|
64
|
-
`Resolving catalog dependency ${packageName}: "${specifier}" -> "${catalogVersion}"
|
|
64
|
+
`Resolving catalog dependency ${packageName}: "${specifier}" -> "${catalogVersion}"`,
|
|
65
65
|
);
|
|
66
66
|
resolved[packageName] = catalogVersion;
|
|
67
67
|
} else {
|
|
68
68
|
log.warn(
|
|
69
|
-
`Catalog dependency ${packageName} references "${specifier}" but it's not found in the catalog. Keeping original specifier
|
|
69
|
+
`Catalog dependency ${packageName} references "${specifier}" but it's not found in the catalog. Keeping original specifier.`,
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/lib/manifest/io.ts
CHANGED
|
@@ -9,10 +9,10 @@ export async function readManifest(packageDir: string) {
|
|
|
9
9
|
|
|
10
10
|
export async function writeManifest(
|
|
11
11
|
outputDir: string,
|
|
12
|
-
manifest: PackageManifest
|
|
12
|
+
manifest: PackageManifest,
|
|
13
13
|
) {
|
|
14
14
|
await fs.writeFile(
|
|
15
15
|
path.join(outputDir, "package.json"),
|
|
16
|
-
JSON.stringify(manifest, null, 2)
|
|
16
|
+
JSON.stringify(manifest, null, 2),
|
|
17
17
|
);
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
expect(() =>
|
|
24
|
-
validateManifestMandatoryFields(validManifest, packagePath)
|
|
24
|
+
validateManifestMandatoryFields(validManifest, packagePath),
|
|
25
25
|
).not.toThrow();
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
expect(() =>
|
|
35
|
-
validateManifestMandatoryFields(devPackageManifest, packagePath, false)
|
|
35
|
+
validateManifestMandatoryFields(devPackageManifest, packagePath, false),
|
|
36
36
|
).not.toThrow();
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
42
42
|
} as PackageManifest;
|
|
43
43
|
|
|
44
44
|
expect(() =>
|
|
45
|
-
validateManifestMandatoryFields(invalidDevManifest, packagePath, false)
|
|
45
|
+
validateManifestMandatoryFields(invalidDevManifest, packagePath, false),
|
|
46
46
|
).toThrow(/missing mandatory fields: version/);
|
|
47
47
|
});
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
53
53
|
} as PackageManifest;
|
|
54
54
|
|
|
55
55
|
expect(() =>
|
|
56
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
56
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
57
57
|
).toThrow(/missing mandatory fields: version/);
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
64
64
|
} as PackageManifest;
|
|
65
65
|
|
|
66
66
|
expect(() =>
|
|
67
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
67
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
68
68
|
).toThrow(/missing mandatory fields: files/);
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -76,7 +76,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
expect(() =>
|
|
79
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
79
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
80
80
|
).toThrow(/missing mandatory fields: files/);
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -88,7 +88,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
expect(() =>
|
|
91
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
91
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
92
92
|
).toThrow(/missing mandatory fields: files/);
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -98,7 +98,7 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
98
98
|
} as PackageManifest;
|
|
99
99
|
|
|
100
100
|
expect(() =>
|
|
101
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
101
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
102
102
|
).toThrow(/missing mandatory fields: version, files/);
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -108,11 +108,11 @@ describe("validateManifestMandatoryFields", () => {
|
|
|
108
108
|
} as PackageManifest;
|
|
109
109
|
|
|
110
110
|
expect(() =>
|
|
111
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
111
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
112
112
|
).toThrow(/missing mandatory fields: version, files/);
|
|
113
113
|
|
|
114
114
|
expect(() =>
|
|
115
|
-
validateManifestMandatoryFields(invalidManifest, packagePath)
|
|
115
|
+
validateManifestMandatoryFields(invalidManifest, packagePath),
|
|
116
116
|
).toThrow(/See the documentation for more details/);
|
|
117
117
|
});
|
|
118
118
|
});
|
|
@@ -14,7 +14,7 @@ import type { PackageManifest } from "../types";
|
|
|
14
14
|
export function validateManifestMandatoryFields(
|
|
15
15
|
manifest: PackageManifest,
|
|
16
16
|
packagePath: string,
|
|
17
|
-
requireFilesField = true
|
|
17
|
+
requireFilesField = true,
|
|
18
18
|
): void {
|
|
19
19
|
const log = useLogger();
|
|
20
20
|
const missingFields: string[] = [];
|
|
@@ -9,7 +9,7 @@ export async function unpackDependencies(
|
|
|
9
9
|
packedFilesByName: Record<string, string>,
|
|
10
10
|
packagesRegistry: PackagesRegistry,
|
|
11
11
|
tmpDir: string,
|
|
12
|
-
isolateDir: string
|
|
12
|
+
isolateDir: string,
|
|
13
13
|
) {
|
|
14
14
|
const log = useLogger();
|
|
15
15
|
|
|
@@ -33,9 +33,9 @@ export async function unpackDependencies(
|
|
|
33
33
|
log.debug(
|
|
34
34
|
`Moved package files to ${getIsolateRelativeLogPath(
|
|
35
35
|
destinationDir,
|
|
36
|
-
isolateDir
|
|
37
|
-
)}
|
|
36
|
+
isolateDir,
|
|
37
|
+
)}`,
|
|
38
38
|
);
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
40
|
);
|
|
41
41
|
}
|
|
@@ -13,7 +13,7 @@ export function inferFromManifest(workspaceRoot: string) {
|
|
|
13
13
|
|
|
14
14
|
const { packageManager: packageManagerString } =
|
|
15
15
|
readTypedJsonSync<PackageManifest>(
|
|
16
|
-
path.join(workspaceRoot, "package.json")
|
|
16
|
+
path.join(workspaceRoot, "package.json"),
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
if (!packageManagerString) {
|
|
@@ -28,14 +28,14 @@ export function inferFromManifest(workspaceRoot: string) {
|
|
|
28
28
|
|
|
29
29
|
assert(
|
|
30
30
|
supportedPackageManagerNames.includes(name),
|
|
31
|
-
`Package manager "${name}" is not currently supported
|
|
31
|
+
`Package manager "${name}" is not currently supported`,
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const lockfileName = getLockfileFileName(name);
|
|
35
35
|
|
|
36
36
|
assert(
|
|
37
37
|
fs.existsSync(path.join(workspaceRoot, lockfileName)),
|
|
38
|
-
`Manifest declares ${name} to be the packageManager, but failed to find ${lockfileName} in workspace root
|
|
38
|
+
`Manifest declares ${name} to be the packageManager, but failed to find ${lockfileName} in workspace root`,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
return {
|
|
@@ -10,7 +10,7 @@ let packageManager: PackageManager | undefined;
|
|
|
10
10
|
export function usePackageManager() {
|
|
11
11
|
if (!packageManager) {
|
|
12
12
|
throw Error(
|
|
13
|
-
"No package manager detected. Make sure to call detectPackageManager() before usePackageManager()"
|
|
13
|
+
"No package manager detected. Make sure to call detectPackageManager() before usePackageManager()",
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -25,7 +25,7 @@ export function usePackageManager() {
|
|
|
25
25
|
export function detectPackageManager(workspaceRootDir: string): PackageManager {
|
|
26
26
|
if (isRushWorkspace(workspaceRootDir)) {
|
|
27
27
|
packageManager = inferFromFiles(
|
|
28
|
-
path.join(workspaceRootDir, "common/config/rush")
|
|
28
|
+
path.join(workspaceRootDir, "common/config/rush"),
|
|
29
29
|
);
|
|
30
30
|
} else {
|
|
31
31
|
/**
|
|
@@ -46,7 +46,7 @@ vi.mock("~/lib/logger", () => ({
|
|
|
46
46
|
|
|
47
47
|
const fs = vi.mocked((await import("fs-extra")).default);
|
|
48
48
|
const { filterPatchedDependencies, readTypedJson } = vi.mocked(
|
|
49
|
-
await import("~/lib/utils")
|
|
49
|
+
await import("~/lib/utils"),
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
describe("copyPatches", () => {
|
|
@@ -146,7 +146,7 @@ describe("copyPatches", () => {
|
|
|
146
146
|
expect(fs.ensureDir).toHaveBeenCalledWith("/workspace/isolate/patches");
|
|
147
147
|
expect(fs.copy).toHaveBeenCalledWith(
|
|
148
148
|
"/workspace/patches/lodash.patch",
|
|
149
|
-
"/workspace/isolate/patches/lodash.patch"
|
|
149
|
+
"/workspace/isolate/patches/lodash.patch",
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
152
|
|
|
@@ -190,7 +190,7 @@ describe("copyPatches", () => {
|
|
|
190
190
|
});
|
|
191
191
|
expect(fs.copy).toHaveBeenCalledWith(
|
|
192
192
|
"/workspace/patches/vitest.patch",
|
|
193
|
-
"/workspace/isolate/patches/vitest.patch"
|
|
193
|
+
"/workspace/isolate/patches/vitest.patch",
|
|
194
194
|
);
|
|
195
195
|
});
|
|
196
196
|
|
|
@@ -303,11 +303,11 @@ describe("copyPatches", () => {
|
|
|
303
303
|
expect(fs.copy).toHaveBeenCalledTimes(2);
|
|
304
304
|
expect(fs.copy).toHaveBeenCalledWith(
|
|
305
305
|
"/workspace/patches/v1/fix.patch",
|
|
306
|
-
"/workspace/isolate/patches/v1/fix.patch"
|
|
306
|
+
"/workspace/isolate/patches/v1/fix.patch",
|
|
307
307
|
);
|
|
308
308
|
expect(fs.copy).toHaveBeenCalledWith(
|
|
309
309
|
"/workspace/patches/v2/fix.patch",
|
|
310
|
-
"/workspace/isolate/patches/v2/fix.patch"
|
|
310
|
+
"/workspace/isolate/patches/v2/fix.patch",
|
|
311
311
|
);
|
|
312
312
|
});
|
|
313
313
|
|
|
@@ -346,11 +346,11 @@ describe("copyPatches", () => {
|
|
|
346
346
|
"lodash@4.17.21": { path: "some/nested/path/lodash.patch", hash: "" },
|
|
347
347
|
});
|
|
348
348
|
expect(fs.ensureDir).toHaveBeenCalledWith(
|
|
349
|
-
"/workspace/isolate/some/nested/path"
|
|
349
|
+
"/workspace/isolate/some/nested/path",
|
|
350
350
|
);
|
|
351
351
|
expect(fs.copy).toHaveBeenCalledWith(
|
|
352
352
|
"/workspace/some/nested/path/lodash.patch",
|
|
353
|
-
"/workspace/isolate/some/nested/path/lodash.patch"
|
|
353
|
+
"/workspace/isolate/some/nested/path/lodash.patch",
|
|
354
354
|
);
|
|
355
355
|
});
|
|
356
356
|
|