@vtex/checkout 0.16.6 → 0.17.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/dist/cli.d.ts +2 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.js +10 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +3 -1
- package/dist/commands/create.js +26 -6
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +35 -6
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/scripts-init.d.ts +10 -0
- package/dist/commands/scripts-init.js +58 -0
- package/dist/commands/scripts-init.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/bundler.d.ts +11 -1
- package/dist/lib/bundler.js +49 -21
- package/dist/lib/bundler.js.map +1 -1
- package/dist/lib/checkout-config.d.ts +50 -0
- package/dist/lib/checkout-config.js +179 -0
- package/dist/lib/checkout-config.js.map +1 -0
- package/dist/lib/constants.d.ts +7 -1
- package/dist/lib/constants.js +7 -1
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/extensions-config.d.ts +18 -0
- package/dist/lib/extensions-config.js +12 -0
- package/dist/lib/extensions-config.js.map +1 -0
- package/dist/lib/project-files.d.ts +50 -0
- package/dist/lib/project-files.js +158 -0
- package/dist/lib/project-files.js.map +1 -0
- package/dist/lib/scripts-watcher.d.ts +28 -0
- package/dist/lib/scripts-watcher.js +79 -0
- package/dist/lib/scripts-watcher.js.map +1 -0
- package/dist/scripts/allowed-scripts.d.ts +77 -0
- package/dist/scripts/allowed-scripts.js +97 -0
- package/dist/scripts/allowed-scripts.js.map +1 -0
- package/dist/scripts/define-checkout-config.d.ts +38 -0
- package/dist/scripts/define-checkout-config.js +9 -0
- package/dist/scripts/define-checkout-config.js.map +1 -0
- package/dist/scripts/index.d.ts +5 -0
- package/dist/scripts/index.js +4 -0
- package/dist/scripts/index.js.map +1 -0
- package/dist/scripts/resolve-scripts.d.ts +35 -0
- package/dist/scripts/resolve-scripts.js +285 -0
- package/dist/scripts/resolve-scripts.js.map +1 -0
- package/dist/scripts/types.d.ts +56 -0
- package/dist/scripts/types.js +2 -0
- package/dist/scripts/types.js.map +1 -0
- package/package.json +2 -2
- package/template/checkout.config.ts +13 -0
- package/template/tsconfig.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { pathToFileURL } from 'url';
|
|
4
|
+
import ts from 'typescript';
|
|
5
|
+
import { flattenScriptsConfig, formatScriptIssue, resolveScripts, } from '../scripts/index.js';
|
|
6
|
+
export const CONFIG_FILE_NAME = 'checkout.config.ts';
|
|
7
|
+
// Relative to the project root. `dist/` is already ignored by the template.
|
|
8
|
+
export const GENERATED_DIR = 'dist/generated';
|
|
9
|
+
export const GENERATED_CONFIG_FILE = 'checkout.config.mjs';
|
|
10
|
+
export const GENERATED_MODULE_FILE = 'scripts-entry.ts';
|
|
11
|
+
const GENERATED_HEADER = '// Generated by `checkout build`. Do not edit.';
|
|
12
|
+
// Two edits in the same millisecond must not share an import URL.
|
|
13
|
+
let importCounter = 0;
|
|
14
|
+
const isNotFound = (error) => typeof error === 'object' &&
|
|
15
|
+
error !== null &&
|
|
16
|
+
error.code === 'ENOENT';
|
|
17
|
+
// The thrown value may come from merchant code, so reading it must not throw.
|
|
18
|
+
const errorMessage = (error) => {
|
|
19
|
+
try {
|
|
20
|
+
return error instanceof Error ? String(error.message) : String(error);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return 'unknown error';
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
27
|
+
const generatedModulePath = (projectPath) => path.join(projectPath, GENERATED_DIR, GENERATED_MODULE_FILE);
|
|
28
|
+
/**
|
|
29
|
+
* Compiles the merchant config to an ES module without type checking. The file
|
|
30
|
+
* must be self-contained: any relative or absolute import is rejected because
|
|
31
|
+
* only the transpiled file is written to `dist/generated`, so it could not
|
|
32
|
+
* resolve its siblings.
|
|
33
|
+
*/
|
|
34
|
+
export function transpileCheckoutConfig(source) {
|
|
35
|
+
const { importedFiles } = ts.preProcessFile(source, true, true);
|
|
36
|
+
const forbidden = importedFiles.find(({ fileName }) => /^[./]/.test(fileName));
|
|
37
|
+
if (forbidden) {
|
|
38
|
+
return {
|
|
39
|
+
error: `Relative imports are not supported in ${CONFIG_FILE_NAME}. Found: "${forbidden.fileName}". Keep the file self-contained.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const { outputText } = ts.transpileModule(source, {
|
|
43
|
+
compilerOptions: {
|
|
44
|
+
module: ts.ModuleKind.ESNext,
|
|
45
|
+
target: ts.ScriptTarget.ES2020,
|
|
46
|
+
isolatedModules: true,
|
|
47
|
+
removeComments: true,
|
|
48
|
+
},
|
|
49
|
+
fileName: CONFIG_FILE_NAME,
|
|
50
|
+
});
|
|
51
|
+
return { code: outputText };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Renders the generated `./scripts` module. Self-contained, deterministic and
|
|
55
|
+
* free of URLs, attributes or script text: only ids, slots and param values.
|
|
56
|
+
*/
|
|
57
|
+
export function renderScriptsModule(entries) {
|
|
58
|
+
if (entries.length === 0)
|
|
59
|
+
return `${GENERATED_HEADER}\nexport default [];\n`;
|
|
60
|
+
const lines = entries.map((entry) => {
|
|
61
|
+
const params = Object.entries(entry.params).map(([name, value]) => `${JSON.stringify(name)}: ${JSON.stringify(value)}`);
|
|
62
|
+
const paramsText = params.length > 0 ? `{ ${params.join(', ')} }` : '{}';
|
|
63
|
+
return ` { "id": ${JSON.stringify(entry.id)}, "slot": ${JSON.stringify(entry.slot)}, "params": ${paramsText} }`;
|
|
64
|
+
});
|
|
65
|
+
return `${GENERATED_HEADER}\nexport default [\n${lines.join(',\n')}\n];\n`;
|
|
66
|
+
}
|
|
67
|
+
const removeFile = async (filePath) => {
|
|
68
|
+
try {
|
|
69
|
+
await fs.unlink(filePath);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (!isNotFound(error))
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export const removeGeneratedScriptsModule = (projectPath) => removeFile(generatedModulePath(projectPath));
|
|
77
|
+
/**
|
|
78
|
+
* Loads and validates `checkout.config.ts` and, when valid, writes the module
|
|
79
|
+
* that the bundler exposes as `./scripts`. The generated `./scripts` module is
|
|
80
|
+
* neither written nor removed when the config is invalid. The transpiled copy
|
|
81
|
+
* of the config only exists while it is being imported: it sits inside the
|
|
82
|
+
* webpack output directory, so it is deleted right after, even on failure.
|
|
83
|
+
*/
|
|
84
|
+
export async function prepareScriptsModule(projectPath, deps = {}) {
|
|
85
|
+
const importModule = deps.importModule ?? ((fileUrl) => import(fileUrl));
|
|
86
|
+
const configPath = path.join(projectPath, CONFIG_FILE_NAME);
|
|
87
|
+
let source;
|
|
88
|
+
try {
|
|
89
|
+
source = await fs.readFile(configPath, 'utf8');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (!isNotFound(error)) {
|
|
93
|
+
return {
|
|
94
|
+
status: 'invalid',
|
|
95
|
+
messages: [
|
|
96
|
+
`Could not load ${CONFIG_FILE_NAME}: ${errorMessage(error)}`,
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (deps.removeStaleModule !== false) {
|
|
101
|
+
await removeGeneratedScriptsModule(projectPath);
|
|
102
|
+
}
|
|
103
|
+
return { status: 'absent' };
|
|
104
|
+
}
|
|
105
|
+
const transpiled = transpileCheckoutConfig(source);
|
|
106
|
+
if ('error' in transpiled) {
|
|
107
|
+
return { status: 'invalid', messages: [transpiled.error] };
|
|
108
|
+
}
|
|
109
|
+
const generatedDir = path.join(projectPath, GENERATED_DIR);
|
|
110
|
+
const mjsPath = path.join(generatedDir, GENERATED_CONFIG_FILE);
|
|
111
|
+
let loaded;
|
|
112
|
+
try {
|
|
113
|
+
await fs.mkdir(generatedDir, { recursive: true });
|
|
114
|
+
await fs.writeFile(mjsPath, transpiled.code);
|
|
115
|
+
// The query string defeats the ES module cache so `dev` sees fresh edits.
|
|
116
|
+
// Node never evicts those modules, so a long `checkout dev` session keeps
|
|
117
|
+
// one copy per save in memory, together with any timer or handle the
|
|
118
|
+
// merchant's config creates at the top level. Restarting `checkout dev`
|
|
119
|
+
// releases them (see the `checkout dev` help).
|
|
120
|
+
loaded = await importModule(`${pathToFileURL(mjsPath).href}?v=${Date.now()}-${++importCounter}`);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return {
|
|
124
|
+
status: 'invalid',
|
|
125
|
+
messages: [`Could not load ${CONFIG_FILE_NAME}: ${errorMessage(error)}`],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
// Best effort: a leftover copy must not turn a valid config into a failure.
|
|
130
|
+
await removeFile(mjsPath).catch(() => undefined);
|
|
131
|
+
}
|
|
132
|
+
let config;
|
|
133
|
+
let scripts;
|
|
134
|
+
// The config is merchant code: a getter or proxy on `default` or `scripts`
|
|
135
|
+
// can throw, and that must end as an invalid config, not a crash.
|
|
136
|
+
try {
|
|
137
|
+
config = isPlainObject(loaded) ? loaded.default : undefined;
|
|
138
|
+
if (isPlainObject(config))
|
|
139
|
+
scripts = config.scripts;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return {
|
|
143
|
+
status: 'invalid',
|
|
144
|
+
messages: [`Could not load ${CONFIG_FILE_NAME}: ${errorMessage(error)}`],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (!isPlainObject(config)) {
|
|
148
|
+
return {
|
|
149
|
+
status: 'invalid',
|
|
150
|
+
messages: [
|
|
151
|
+
`${CONFIG_FILE_NAME} must export default defineCheckoutConfig({ ... }).`,
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const flattened = flattenScriptsConfig(scripts);
|
|
156
|
+
const resolution = resolveScripts(flattened.entries);
|
|
157
|
+
const issues = [...flattened.issues, ...resolution.issues];
|
|
158
|
+
if (issues.length > 0) {
|
|
159
|
+
return { status: 'invalid', messages: issues.map(formatScriptIssue) };
|
|
160
|
+
}
|
|
161
|
+
// The validated copies, never `flattened.entries`: those are untrusted and
|
|
162
|
+
// their params could change between validation and this point.
|
|
163
|
+
const entries = resolution.accepted;
|
|
164
|
+
const text = renderScriptsModule(entries);
|
|
165
|
+
const modulePath = generatedModulePath(projectPath);
|
|
166
|
+
let previous = null;
|
|
167
|
+
try {
|
|
168
|
+
previous = await fs.readFile(modulePath, 'utf8');
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (!isNotFound(error))
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
const changed = previous !== text;
|
|
175
|
+
if (changed)
|
|
176
|
+
await fs.writeFile(modulePath, text);
|
|
177
|
+
return { status: 'valid', entries, changed };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=checkout-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-config.js","sourceRoot":"","sources":["../../src/lib/checkout-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,C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,UAAU,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACpD,IAAI,QAAQ,GAAkB,IAAI,CAAC;IAEnC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;IACtC,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC;IAElC,IAAI,OAAO;QAAE,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAElD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC/C,CAAC"}
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export declare const PACKAGE_PATH: string;
|
|
2
2
|
export declare const UI_CORE_PATH: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const TEMPLATE_DIR = "template";
|
|
4
|
+
/**
|
|
5
|
+
* The template ships inside `@vtex/checkout`, so it is resolved from the root
|
|
6
|
+
* of the package that runs the command (oclif's `this.config.root`), never
|
|
7
|
+
* from the working directory.
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveTemplatePath: (packageRoot: string) => string;
|
|
4
10
|
export declare const PACKAGE_JSON_TEMPLATE = "package.template.json";
|
|
5
11
|
export declare const GITIGNORE_TEMPLATE = ".gitignore.template";
|
|
6
12
|
export declare const NEXT_APP_PATH: string;
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
export const PACKAGE_PATH = path.resolve('node_modules', '@vtex', 'checkout');
|
|
3
3
|
export const UI_CORE_PATH = path.resolve('node_modules', '@vtex', 'checkout-ui-core');
|
|
4
|
-
export const
|
|
4
|
+
export const TEMPLATE_DIR = 'template';
|
|
5
|
+
/**
|
|
6
|
+
* The template ships inside `@vtex/checkout`, so it is resolved from the root
|
|
7
|
+
* of the package that runs the command (oclif's `this.config.root`), never
|
|
8
|
+
* from the working directory.
|
|
9
|
+
*/
|
|
10
|
+
export const resolveTemplatePath = (packageRoot) => path.join(packageRoot, TEMPLATE_DIR);
|
|
5
11
|
export const PACKAGE_JSON_TEMPLATE = 'package.template.json';
|
|
6
12
|
export const GITIGNORE_TEMPLATE = '.gitignore.template';
|
|
7
13
|
export const NEXT_APP_PATH = path.resolve(UI_CORE_PATH, '.next');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CACtC,cAAc,EACd,OAAO,EACP,kBAAkB,CACnB,CAAC;AACF,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CACtC,cAAc,EACd,OAAO,EACP,kBAAkB,CACnB,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAU,EAAE,CACjE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ExtensionsConfigInput = {
|
|
2
|
+
accountName: string;
|
|
3
|
+
extensionsServerPort: number | string;
|
|
4
|
+
showPlaceholders: boolean;
|
|
5
|
+
/** `checkout dev --with-scripts`. */
|
|
6
|
+
withScripts: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The JSON that `GET /extensions-config` returns to the local checkout UI.
|
|
10
|
+
* `withScripts` is `true` only when the developer passed `--with-scripts`;
|
|
11
|
+
* the UI reads it in development mode only, so no build variable is needed.
|
|
12
|
+
*/
|
|
13
|
+
export declare const buildExtensionsConfig: ({ accountName, extensionsServerPort, showPlaceholders, withScripts, }: ExtensionsConfigInput) => {
|
|
14
|
+
accountName: string;
|
|
15
|
+
extensionsServerPort: string | number;
|
|
16
|
+
showPlaceholders: boolean;
|
|
17
|
+
withScripts: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The JSON that `GET /extensions-config` returns to the local checkout UI.
|
|
3
|
+
* `withScripts` is `true` only when the developer passed `--with-scripts`;
|
|
4
|
+
* the UI reads it in development mode only, so no build variable is needed.
|
|
5
|
+
*/
|
|
6
|
+
export const buildExtensionsConfig = ({ accountName, extensionsServerPort, showPlaceholders, withScripts, }) => ({
|
|
7
|
+
accountName,
|
|
8
|
+
extensionsServerPort,
|
|
9
|
+
showPlaceholders,
|
|
10
|
+
withScripts: withScripts === true,
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=extensions-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions-config.js","sourceRoot":"","sources":["../../src/lib/extensions-config.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,GACW,EAAE,EAAE,CAAC,CAAC;IAC5B,WAAW;IACX,oBAAoB;IACpB,gBAAgB;IAChB,WAAW,EAAE,WAAW,KAAK,IAAI;CAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const CHECKOUT_CONFIG_FILE = "checkout.config.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Lists the files `checkout create` writes into the target, relative to it,
|
|
4
|
+
* sorted and with `/` separators (the template files, with the two renames).
|
|
5
|
+
*/
|
|
6
|
+
export declare function listTemplateFiles(templatePath: string): Promise<string[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the files that `checkout create` would write which already exist
|
|
9
|
+
* under `projectPath`, in `listTemplateFiles` order. Used to refuse
|
|
10
|
+
* overwriting anything of the user's.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findTemplateConflicts(args: {
|
|
13
|
+
projectPath: string;
|
|
14
|
+
templatePath: string;
|
|
15
|
+
}): Promise<string[]>;
|
|
16
|
+
export type TsconfigOutcome = {
|
|
17
|
+
kind: 'covered';
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'inserted';
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'manual';
|
|
22
|
+
instruction: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'no-tsconfig';
|
|
25
|
+
notice: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'failed';
|
|
28
|
+
warning: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Makes sure `tsconfig.json` type-checks `checkout.config.ts`. It only edits
|
|
32
|
+
* text (never re-serializes), so comments, trailing commas and formatting are
|
|
33
|
+
* preserved. See the spec, Decision 5.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureTsconfigIncludesConfig(projectPath: string): Promise<TsconfigOutcome>;
|
|
36
|
+
/**
|
|
37
|
+
* Writes `checkout.config.ts` from the template and makes sure `tsconfig.json`
|
|
38
|
+
* covers it. A failure to update `tsconfig.json` is returned as a
|
|
39
|
+
* `failed` outcome, because the config file was already written. Never overwrites an existing config and never touches
|
|
40
|
+
* `src/index.tsx` or `package.json`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function initScriptsConfig(args: {
|
|
43
|
+
projectPath: string;
|
|
44
|
+
templatePath: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
created: true;
|
|
47
|
+
tsconfig: TsconfigOutcome;
|
|
48
|
+
} | {
|
|
49
|
+
created: false;
|
|
50
|
+
}>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import { constants as fsConstants } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import ts from 'typescript';
|
|
5
|
+
import { GITIGNORE_TEMPLATE, PACKAGE_JSON_TEMPLATE } from './constants.js';
|
|
6
|
+
export const CHECKOUT_CONFIG_FILE = 'checkout.config.ts';
|
|
7
|
+
const TSCONFIG_FILE = 'tsconfig.json';
|
|
8
|
+
const exists = async (file) => {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(file);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The files `checkout create` writes differ from the template's names for two
|
|
19
|
+
* entries, which are stored under a different name so they do not act as real
|
|
20
|
+
* project files inside this package.
|
|
21
|
+
*/
|
|
22
|
+
const TEMPLATE_RENAMES = {
|
|
23
|
+
[PACKAGE_JSON_TEMPLATE]: 'package.json',
|
|
24
|
+
[GITIGNORE_TEMPLATE]: '.gitignore',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Lists the files `checkout create` writes into the target, relative to it,
|
|
28
|
+
* sorted and with `/` separators (the template files, with the two renames).
|
|
29
|
+
*/
|
|
30
|
+
export async function listTemplateFiles(templatePath) {
|
|
31
|
+
const walk = async (directory) => {
|
|
32
|
+
const entries = await fs.readdir(directory, { withFileTypes: true });
|
|
33
|
+
const nested = await Promise.all(entries.map(async (entry) => {
|
|
34
|
+
const fullPath = path.join(directory, entry.name);
|
|
35
|
+
return entry.isDirectory() ? walk(fullPath) : [fullPath];
|
|
36
|
+
}));
|
|
37
|
+
return nested.flat();
|
|
38
|
+
};
|
|
39
|
+
const files = await walk(templatePath);
|
|
40
|
+
return files
|
|
41
|
+
.map((file) => path.relative(templatePath, file).split(path.sep).join('/'))
|
|
42
|
+
.map((file) => TEMPLATE_RENAMES[file] ?? file)
|
|
43
|
+
.sort();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the files that `checkout create` would write which already exist
|
|
47
|
+
* under `projectPath`, in `listTemplateFiles` order. Used to refuse
|
|
48
|
+
* overwriting anything of the user's.
|
|
49
|
+
*/
|
|
50
|
+
export async function findTemplateConflicts(args) {
|
|
51
|
+
const { projectPath, templatePath } = args;
|
|
52
|
+
const files = await listTemplateFiles(templatePath);
|
|
53
|
+
const found = await Promise.all(files.map(async (file) => (await exists(path.join(projectPath, file))) ? file : null));
|
|
54
|
+
return found.filter((file) => Boolean(file));
|
|
55
|
+
}
|
|
56
|
+
const INCLUDE_INSTRUCTION = `Add "${CHECKOUT_CONFIG_FILE}" to the "include" list in ${TSCONFIG_FILE} (if the list is inherited through "extends", declare "include" there with your current entries plus this file).`;
|
|
57
|
+
const FILES_INSTRUCTION = `Add "${CHECKOUT_CONFIG_FILE}" to the "files" array in ${TSCONFIG_FILE}.`;
|
|
58
|
+
const UNPARSABLE_INSTRUCTION = `${TSCONFIG_FILE} could not be parsed, so it was not changed. Make sure it includes "${CHECKOUT_CONFIG_FILE}" so the file is type-checked.`;
|
|
59
|
+
const normalize = (file) => path.resolve(file).replace(/\\/g, '/');
|
|
60
|
+
const getTopLevelProperty = (sourceFile, name) => {
|
|
61
|
+
const statement = sourceFile.statements[0];
|
|
62
|
+
const root = statement?.expression;
|
|
63
|
+
if (!root || !ts.isObjectLiteralExpression(root)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return root.properties.find((property) => ts.isPropertyAssignment(property) &&
|
|
67
|
+
ts.isStringLiteral(property.name) &&
|
|
68
|
+
property.name.text === name);
|
|
69
|
+
};
|
|
70
|
+
// JSON only parses double-quoted strings (a single-quoted tsconfig.json is
|
|
71
|
+
// reported as unparsable and never reaches this point), so the quote is fixed.
|
|
72
|
+
const ENTRY = `"${CHECKOUT_CONFIG_FILE}"`;
|
|
73
|
+
const insertIntoIncludeArray = (text, sourceFile, array) => {
|
|
74
|
+
const last = array.elements[array.elements.length - 1];
|
|
75
|
+
if (!last) {
|
|
76
|
+
const position = array.getStart(sourceFile) + 1;
|
|
77
|
+
return `${text.slice(0, position)}${ENTRY}${text.slice(position)}`;
|
|
78
|
+
}
|
|
79
|
+
const position = last.getEnd();
|
|
80
|
+
return `${text.slice(0, position)}, ${ENTRY}${text.slice(position)}`;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Makes sure `tsconfig.json` type-checks `checkout.config.ts`. It only edits
|
|
84
|
+
* text (never re-serializes), so comments, trailing commas and formatting are
|
|
85
|
+
* preserved. See the spec, Decision 5.
|
|
86
|
+
*/
|
|
87
|
+
export async function ensureTsconfigIncludesConfig(projectPath) {
|
|
88
|
+
const tsconfigPath = path.join(projectPath, TSCONFIG_FILE);
|
|
89
|
+
let text;
|
|
90
|
+
try {
|
|
91
|
+
text = await fs.readFile(tsconfigPath, 'utf8');
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error.code === 'ENOENT') {
|
|
95
|
+
return {
|
|
96
|
+
kind: 'no-tsconfig',
|
|
97
|
+
notice: `No ${TSCONFIG_FILE} found, so ${CHECKOUT_CONFIG_FILE} is not type-checked until a ${TSCONFIG_FILE} includes it.`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
const parsed = ts.parseConfigFileTextToJson(tsconfigPath, text);
|
|
103
|
+
if (parsed.error ||
|
|
104
|
+
typeof parsed.config !== 'object' ||
|
|
105
|
+
parsed.config === null ||
|
|
106
|
+
Array.isArray(parsed.config)) {
|
|
107
|
+
return { kind: 'manual', instruction: UNPARSABLE_INSTRUCTION };
|
|
108
|
+
}
|
|
109
|
+
const resolved = ts.parseJsonConfigFileContent(parsed.config, ts.sys, projectPath, undefined, tsconfigPath);
|
|
110
|
+
const configFile = normalize(path.join(projectPath, CHECKOUT_CONFIG_FILE));
|
|
111
|
+
if (resolved.fileNames.some((file) => normalize(file) === configFile)) {
|
|
112
|
+
return { kind: 'covered' };
|
|
113
|
+
}
|
|
114
|
+
const sourceFile = ts.parseJsonText(tsconfigPath, text);
|
|
115
|
+
const include = getTopLevelProperty(sourceFile, 'include');
|
|
116
|
+
if (include && ts.isArrayLiteralExpression(include.initializer)) {
|
|
117
|
+
await fs.writeFile(tsconfigPath, insertIntoIncludeArray(text, sourceFile, include.initializer));
|
|
118
|
+
return { kind: 'inserted' };
|
|
119
|
+
}
|
|
120
|
+
const hasOwnFiles = Boolean(getTopLevelProperty(sourceFile, 'files'));
|
|
121
|
+
return {
|
|
122
|
+
kind: 'manual',
|
|
123
|
+
instruction: hasOwnFiles ? FILES_INSTRUCTION : INCLUDE_INSTRUCTION,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Writes `checkout.config.ts` from the template and makes sure `tsconfig.json`
|
|
128
|
+
* covers it. A failure to update `tsconfig.json` is returned as a
|
|
129
|
+
* `failed` outcome, because the config file was already written. Never overwrites an existing config and never touches
|
|
130
|
+
* `src/index.tsx` or `package.json`.
|
|
131
|
+
*/
|
|
132
|
+
export async function initScriptsConfig(args) {
|
|
133
|
+
const { projectPath, templatePath } = args;
|
|
134
|
+
try {
|
|
135
|
+
await fs.copyFile(path.join(templatePath, CHECKOUT_CONFIG_FILE), path.join(projectPath, CHECKOUT_CONFIG_FILE), fsConstants.COPYFILE_EXCL);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error.code === 'EEXIST') {
|
|
139
|
+
return { created: false };
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
let tsconfig;
|
|
144
|
+
try {
|
|
145
|
+
tsconfig = await ensureTsconfigIncludesConfig(projectPath);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
// The config file already exists at this point, so a tsconfig failure must
|
|
149
|
+
// not be reported as a failure to create it.
|
|
150
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
151
|
+
tsconfig = {
|
|
152
|
+
kind: 'failed',
|
|
153
|
+
warning: `${TSCONFIG_FILE} could not be updated (${reason}). ${INCLUDE_INSTRUCTION}`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return { created: true, tsconfig };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=project-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../src/lib/project-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,IAAI,C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KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IACD,IAAI,QAAyB,CAAC;IAC9B,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2EAA2E;QAC3E,6CAA6C;QAC7C,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,QAAQ,GAAG;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,GAAG,aAAa,0BAA0B,MAAM,MAAM,mBAAmB,EAAE;SACrF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { watch as fsWatch } from 'fs';
|
|
2
|
+
import { type PrepareResult } from './checkout-config.js';
|
|
3
|
+
type WatchScriptsConfigArgs = {
|
|
4
|
+
projectPath: string;
|
|
5
|
+
initiallyExposed: boolean;
|
|
6
|
+
debounceMs?: number;
|
|
7
|
+
deps?: {
|
|
8
|
+
watch?: typeof fsWatch;
|
|
9
|
+
prepare?: (projectPath: string) => Promise<PrepareResult>;
|
|
10
|
+
removeModule?: (projectPath: string) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/** Closes the old compiler and starts a new one. */
|
|
13
|
+
restartCompiler: (exposeScripts: boolean) => Promise<void>;
|
|
14
|
+
/** Overrides the default logger (issues use `logger.error`, status `logger.info`). */
|
|
15
|
+
log?: (line: string) => void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Watches `checkout.config.ts` in `checkout dev`. Each change re-validates the
|
|
19
|
+
* file and regenerates `./scripts`. The compiler is recreated only when the
|
|
20
|
+
* file appears or disappears, because that is the only time the Module
|
|
21
|
+
* Federation `exposes` map changes. An invalid edit keeps all state. When the
|
|
22
|
+
* file disappears, the stale module is removed only after the compiler that
|
|
23
|
+
* still exposes it is closed, so webpack never sees a missing entry.
|
|
24
|
+
*/
|
|
25
|
+
export declare function watchScriptsConfig({ projectPath, initiallyExposed, debounceMs, deps, restartCompiler, log, }: WatchScriptsConfigArgs): {
|
|
26
|
+
close: () => void;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { watch as fsWatch } from 'fs';
|
|
2
|
+
import { CONFIG_FILE_NAME, prepareScriptsModule, removeGeneratedScriptsModule, } from './checkout-config.js';
|
|
3
|
+
import { logger } from './logger.js';
|
|
4
|
+
const DEFAULT_DEBOUNCE_MS = 150;
|
|
5
|
+
/**
|
|
6
|
+
* Watches `checkout.config.ts` in `checkout dev`. Each change re-validates the
|
|
7
|
+
* file and regenerates `./scripts`. The compiler is recreated only when the
|
|
8
|
+
* file appears or disappears, because that is the only time the Module
|
|
9
|
+
* Federation `exposes` map changes. An invalid edit keeps all state. When the
|
|
10
|
+
* file disappears, the stale module is removed only after the compiler that
|
|
11
|
+
* still exposes it is closed, so webpack never sees a missing entry.
|
|
12
|
+
*/
|
|
13
|
+
export function watchScriptsConfig({ projectPath, initiallyExposed, debounceMs = DEFAULT_DEBOUNCE_MS, deps = {}, restartCompiler, log, }) {
|
|
14
|
+
const watch = deps.watch ?? fsWatch;
|
|
15
|
+
const prepare = deps.prepare ??
|
|
16
|
+
((path) => prepareScriptsModule(path, { removeStaleModule: false }));
|
|
17
|
+
const removeModule = deps.removeModule ?? removeGeneratedScriptsModule;
|
|
18
|
+
const logIssue = log ?? ((line) => logger.error(line));
|
|
19
|
+
const logStatus = log ?? ((line) => logger.info(line));
|
|
20
|
+
let exposed = initiallyExposed;
|
|
21
|
+
let closed = false;
|
|
22
|
+
let timer = null;
|
|
23
|
+
let chain = Promise.resolve();
|
|
24
|
+
const processChange = async () => {
|
|
25
|
+
if (closed)
|
|
26
|
+
return;
|
|
27
|
+
const result = await prepare(projectPath);
|
|
28
|
+
if (closed)
|
|
29
|
+
return;
|
|
30
|
+
if (result.status === 'invalid') {
|
|
31
|
+
logIssue(`❌ ${CONFIG_FILE_NAME} is invalid. Keeping the previous state:`);
|
|
32
|
+
result.messages.forEach((line) => logIssue(` - ${line}`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const desired = result.status === 'valid';
|
|
36
|
+
if (desired === exposed) {
|
|
37
|
+
logStatus(`🔄 ${CONFIG_FILE_NAME} changed. Updating ./scripts`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
logStatus(desired
|
|
41
|
+
? `🔄 ${CONFIG_FILE_NAME} was added. Restarting the compiler to expose ./scripts`
|
|
42
|
+
: `🔄 ${CONFIG_FILE_NAME} was removed. Restarting the compiler without ./scripts`);
|
|
43
|
+
await restartCompiler(desired);
|
|
44
|
+
exposed = desired;
|
|
45
|
+
}
|
|
46
|
+
if (result.status === 'absent')
|
|
47
|
+
await removeModule(projectPath);
|
|
48
|
+
};
|
|
49
|
+
const enqueue = () => {
|
|
50
|
+
chain = chain.then(processChange).catch((error) => {
|
|
51
|
+
logIssue(`❌ Could not apply ${CONFIG_FILE_NAME} changes: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const watcher = watch(projectPath, (_event, filename) => {
|
|
55
|
+
if (closed || filename === null || filename === undefined)
|
|
56
|
+
return;
|
|
57
|
+
if (String(filename) !== CONFIG_FILE_NAME)
|
|
58
|
+
return;
|
|
59
|
+
if (timer !== null)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
timer = setTimeout(() => {
|
|
62
|
+
timer = null;
|
|
63
|
+
enqueue();
|
|
64
|
+
}, debounceMs);
|
|
65
|
+
});
|
|
66
|
+
watcher.on('error', (error) => {
|
|
67
|
+
logIssue(`❌ Stopped watching ${CONFIG_FILE_NAME}: ${error.message}`);
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
close: () => {
|
|
71
|
+
closed = true;
|
|
72
|
+
if (timer !== null)
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
timer = null;
|
|
75
|
+
watcher.close();
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=scripts-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts-watcher.js","sourceRoot":"","sources":["../../src/lib/scripts-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,IAAI,CAAC;AAEtC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,4BAA4B,GAE7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAiBrC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,EACX,gBAAgB,EAChB,UAAU,GAAG,mBAAmB,EAChC,IAAI,GAAG,EAAE,EACT,eAAe,EACf,GAAG,GACoB;IACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;IACpC,MAAM,OAAO,GACX,IAAI,CAAC,OAAO;QACZ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACvE,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,4BAA4B,CAAC;IACvE,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D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