sv 0.6.0 → 0.6.2
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/_commonjsHelpers-n7_cr1vO.js +694 -0
- package/dist/_commonjsHelpers-n7_cr1vO.js.map +1 -0
- package/dist/bin.js +506 -44158
- package/dist/bin.js.map +1 -1
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/install.d.ts +14 -0
- package/dist/lib/testing.d.ts +31 -0
- package/dist/processor-SieBGHed.js +43144 -0
- package/dist/processor-SieBGHed.js.map +1 -0
- package/dist/shared.json +8 -0
- package/dist/testing.js +15581 -0
- package/dist/testing.js.map +1 -0
- package/package.json +12 -4
- package/dist/index-A89HFWzv.js +0 -137
- package/dist/index-A89HFWzv.js.map +0 -1
- package/dist/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
import { b as be } from './_commonjsHelpers-n7_cr1vO.js';
|
|
2
|
+
export { c as create } from './_commonjsHelpers-n7_cr1vO.js';
|
|
3
|
+
import { c as createWorkspace, i as installPackages, a as createOrUpdateFiles, r as resolveCommand } from './processor-SieBGHed.js';
|
|
2
4
|
import 'node:fs';
|
|
3
5
|
import 'node:path';
|
|
4
6
|
import 'node:url';
|
|
7
|
+
import 'node:module';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
import 'path';
|
|
10
|
+
import 'process';
|
|
11
|
+
import 'stream';
|
|
12
|
+
import 'readline';
|
|
13
|
+
import 'node:process';
|
|
14
|
+
import 'node:readline';
|
|
15
|
+
import 'node:tty';
|
|
16
|
+
import 'node:fs/promises';
|
|
17
|
+
import 'os';
|
|
18
|
+
import 'fs';
|
|
19
|
+
import 'url';
|
|
20
|
+
|
|
21
|
+
async function installAddon({
|
|
22
|
+
addons,
|
|
23
|
+
cwd,
|
|
24
|
+
options,
|
|
25
|
+
packageManager = "npm"
|
|
26
|
+
}) {
|
|
27
|
+
const filesToFormat = /* @__PURE__ */ new Set();
|
|
28
|
+
const mapped = Object.entries(addons).map(([, addon]) => addon);
|
|
29
|
+
const ordered = orderAddons(mapped);
|
|
30
|
+
for (const addon of ordered) {
|
|
31
|
+
const workspace = createWorkspace({ cwd, packageManager });
|
|
32
|
+
workspace.options = options[addon.id];
|
|
33
|
+
const files = await runAddon(workspace, addon);
|
|
34
|
+
files.forEach((f) => filesToFormat.add(f));
|
|
35
|
+
}
|
|
36
|
+
return Array.from(filesToFormat);
|
|
37
|
+
}
|
|
38
|
+
async function runAddon(workspace, addon) {
|
|
39
|
+
const files = /* @__PURE__ */ new Set();
|
|
40
|
+
for (const [, question] of Object.entries(addon.options)) {
|
|
41
|
+
if (question.condition?.(workspace.options) !== false) {
|
|
42
|
+
workspace.options ?? (workspace.options = question.default);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
await addon.preInstall?.(workspace);
|
|
46
|
+
const pkgPath = installPackages(addon, workspace);
|
|
47
|
+
files.add(pkgPath);
|
|
48
|
+
const changedFiles = createOrUpdateFiles(addon.files, workspace);
|
|
49
|
+
changedFiles.forEach((file) => files.add(file));
|
|
50
|
+
await addon.postInstall?.(workspace);
|
|
51
|
+
for (const script of addon.scripts ?? []) {
|
|
52
|
+
if (script.condition?.(workspace) === false) continue;
|
|
53
|
+
try {
|
|
54
|
+
const { args, command } = resolveCommand(workspace.packageManager, "execute", script.args);
|
|
55
|
+
if (workspace.packageManager === "npm") args.unshift("--yes");
|
|
56
|
+
await be(command, args, {
|
|
57
|
+
nodeOptions: { cwd: workspace.cwd, stdio: "pipe" },
|
|
58
|
+
throwOnError: true
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
const typedError = error;
|
|
62
|
+
throw new Error(`Failed to execute scripts '${script.description}': ` + typedError.message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return Array.from(files);
|
|
66
|
+
}
|
|
67
|
+
function orderAddons(addons) {
|
|
68
|
+
return Array.from(addons).sort((a, b) => {
|
|
69
|
+
if (!a.dependsOn && !b.dependsOn) return 0;
|
|
70
|
+
if (!a.dependsOn) return -1;
|
|
71
|
+
if (!b.dependsOn) return 1;
|
|
72
|
+
if (a.dependsOn.includes(b.id)) return 1;
|
|
73
|
+
if (b.dependsOn.includes(a.id)) return -1;
|
|
74
|
+
return 0;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { installAddon };
|
|
5
79
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../lib/install.ts"],"sourcesContent":["import { exec } from 'tinyexec';\nimport { resolveCommand } from 'package-manager-detector';\nimport type { Adder, Workspace, PackageManager, OptionValues, Question } from '@sveltejs/cli-core';\nimport { installPackages } from '../commands/add/utils.ts';\nimport { createWorkspace } from '../commands/add/workspace.ts';\nimport { createOrUpdateFiles } from '../commands/add/processor.ts';\n\ntype Addon = Adder<any>;\nexport type InstallOptions<Addons extends AddonMap> = {\n\tcwd: string;\n\taddons: Addons;\n\toptions: OptionMap<Addons>;\n\tpackageManager: PackageManager;\n};\n\nexport type AddonMap = Record<string, Addon>;\nexport type OptionMap<Addons extends AddonMap> = {\n\t[K in keyof Addons]: Partial<OptionValues<Addons[K]['options']>>;\n};\n\nexport async function installAddon<Addons extends AddonMap>({\n\taddons,\n\tcwd,\n\toptions,\n\tpackageManager = 'npm'\n}: InstallOptions<Addons>): Promise<string[]> {\n\tconst filesToFormat = new Set<string>();\n\n\tconst mapped = Object.entries(addons).map(([, addon]) => addon);\n\tconst ordered = orderAddons(mapped);\n\n\tfor (const addon of ordered) {\n\t\tconst workspace = createWorkspace({ cwd, packageManager });\n\t\tworkspace.options = options[addon.id];\n\n\t\tconst files = await runAddon(workspace, addon);\n\t\tfiles.forEach((f) => filesToFormat.add(f));\n\t}\n\n\treturn Array.from(filesToFormat);\n}\n\nasync function runAddon(\n\tworkspace: Workspace<any>,\n\taddon: Adder<Record<string, Question>>\n): Promise<string[]> {\n\tconst files = new Set<string>();\n\n\t// apply default adder options\n\tfor (const [, question] of Object.entries(addon.options)) {\n\t\t// we'll only apply defaults to options that don't explicitly fail their conditions\n\t\tif (question.condition?.(workspace.options) !== false) {\n\t\t\tworkspace.options ??= question.default;\n\t\t}\n\t}\n\n\tawait addon.preInstall?.(workspace);\n\tconst pkgPath = installPackages(addon, workspace);\n\tfiles.add(pkgPath);\n\tconst changedFiles = createOrUpdateFiles(addon.files, workspace);\n\tchangedFiles.forEach((file) => files.add(file));\n\tawait addon.postInstall?.(workspace);\n\n\tfor (const script of addon.scripts ?? []) {\n\t\tif (script.condition?.(workspace) === false) continue;\n\n\t\ttry {\n\t\t\tconst { args, command } = resolveCommand(workspace.packageManager, 'execute', script.args)!;\n\t\t\tif (workspace.packageManager === 'npm') args.unshift('--yes');\n\t\t\tawait exec(command, args, {\n\t\t\t\tnodeOptions: { cwd: workspace.cwd, stdio: 'pipe' },\n\t\t\t\tthrowOnError: true\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconst typedError = error as Error;\n\t\t\tthrow new Error(`Failed to execute scripts '${script.description}': ` + typedError.message);\n\t\t}\n\t}\n\n\treturn Array.from(files);\n}\n\n// sorts them to their execution order\nfunction orderAddons(addons: Addon[]) {\n\treturn Array.from(addons).sort((a, b) => {\n\t\tif (!a.dependsOn && !b.dependsOn) return 0;\n\t\tif (!a.dependsOn) return -1;\n\t\tif (!b.dependsOn) return 1;\n\n\t\tif (a.dependsOn.includes(b.id)) return 1;\n\t\tif (b.dependsOn.includes(a.id)) return -1;\n\n\t\treturn 0;\n\t});\n}\n"],"names":["exec"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,YAAsC,CAAA;AAAA,EAC3D,MAAA;AAAA,EACA,GAAA;AAA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,CAAA,MAAM,EAAE,IAAK,CAAA,CAAC,GAAG,CAAM,KAAA;AACxC,IAAA,IAAI,CAAC,CAAE,CAAA,SAAA,IAAa,CAAC,CAAA,CAAE,WAAkB,OAAA,CAAA,CAAA;AACzC,IAAI,IAAA,CAAC,CAAE,CAAA,SAAA,EAAkB,OAAA,CAAA,CAAA,CAAA;AACzB,IAAI,IAAA,CAAC,CAAE,CAAA,SAAA,EAAkB,OAAA,CAAA,CAAA;AAEzB,IAAA,IAAI,EAAE,SAAU,CAAA,QAAA,CAAS,CAAE,CAAA,EAAE,GAAU,OAAA,CAAA,CAAA;AACvC,IAAA,IAAI,EAAE,SAAU,CAAA,QAAA,CAAS,CAAE,CAAA,EAAE,GAAU,OAAA,CAAA,CAAA,CAAA;AAEvC,IAAO,OAAA,CAAA,CAAA;AAAA,GACP,CAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Adder, PackageManager, OptionValues } from '@sveltejs/cli-core';
|
|
2
|
+
type Addon = Adder<any>;
|
|
3
|
+
export type InstallOptions<Addons extends AddonMap> = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
addons: Addons;
|
|
6
|
+
options: OptionMap<Addons>;
|
|
7
|
+
packageManager: PackageManager;
|
|
8
|
+
};
|
|
9
|
+
export type AddonMap = Record<string, Addon>;
|
|
10
|
+
export type OptionMap<Addons extends AddonMap> = {
|
|
11
|
+
[K in keyof Addons]: Partial<OptionValues<Addons[K]['options']>>;
|
|
12
|
+
};
|
|
13
|
+
export declare function installAddon<Addons extends AddonMap>({ addons, cwd, options, packageManager }: InstallOptions<Addons>): Promise<string[]>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ProjectVariant = 'kit-js' | 'kit-ts' | 'vite-js' | 'vite-ts';
|
|
2
|
+
export type CreateProject = (options: {
|
|
3
|
+
testId: string;
|
|
4
|
+
variant: ProjectVariant;
|
|
5
|
+
/** @default true */
|
|
6
|
+
clean?: boolean;
|
|
7
|
+
}) => string;
|
|
8
|
+
type SetupOptions = {
|
|
9
|
+
cwd: string;
|
|
10
|
+
variants: readonly ProjectVariant[];
|
|
11
|
+
/** @default false */
|
|
12
|
+
clean?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function setup({ cwd, clean, variants }: SetupOptions): Promise<{
|
|
15
|
+
templatesDir: string;
|
|
16
|
+
}>;
|
|
17
|
+
type CreateOptions = {
|
|
18
|
+
cwd: string;
|
|
19
|
+
testName: string;
|
|
20
|
+
templatesDir: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function createProject({ cwd, testName, templatesDir }: CreateOptions): CreateProject;
|
|
23
|
+
type PreviewOptions = {
|
|
24
|
+
cwd: string;
|
|
25
|
+
command?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function startPreview({ cwd, command }: PreviewOptions): Promise<{
|
|
28
|
+
url: string;
|
|
29
|
+
close: () => Promise<void>;
|
|
30
|
+
}>;
|
|
31
|
+
export {};
|