@cedarjs/cli-helpers 9.0.0-canary.1784 → 9.0.0-canary.3124
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/auth/authFiles.d.ts +9 -1
- package/dist/auth/authFiles.d.ts.map +1 -1
- package/dist/auth/authFiles.js +44 -22
- package/dist/auth/authTasks.d.ts +1 -1
- package/dist/auth/authTasks.d.ts.map +1 -1
- package/dist/auth/authTasks.js +21 -14
- package/dist/auth/setupHelpers.d.ts +3 -1
- package/dist/auth/setupHelpers.d.ts.map +1 -1
- package/dist/auth/setupHelpers.js +2 -1
- package/dist/lib/colors.d.ts +7 -5
- package/dist/lib/colors.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +9 -22
- package/dist/lib/installHelpers.d.ts.map +1 -1
- package/dist/lib/installHelpers.js +14 -7
- package/dist/lib/loadEnvFiles.js +2 -2
- package/dist/lib/project.d.ts.map +1 -1
- package/dist/lib/project.js +10 -10
- package/dist/lib/transpileTSToJS.d.ts +18 -0
- package/dist/lib/transpileTSToJS.d.ts.map +1 -0
- package/dist/lib/transpileTSToJS.js +38 -0
- package/dist/lib/tty.d.ts +11 -0
- package/dist/lib/tty.d.ts.map +1 -0
- package/dist/lib/tty.js +16 -0
- package/dist/lib/version.js +5 -5
- package/dist/packageManager/display.d.ts +100 -0
- package/dist/packageManager/display.d.ts.map +1 -0
- package/dist/packageManager/display.js +115 -0
- package/dist/packageManager/exec.d.ts +77 -0
- package/dist/packageManager/exec.d.ts.map +1 -0
- package/dist/packageManager/exec.js +108 -0
- package/dist/packageManager/index.d.ts +13 -0
- package/dist/packageManager/index.d.ts.map +1 -0
- package/dist/packageManager/index.js +43 -0
- package/dist/packageManager/packages.d.ts +39 -0
- package/dist/packageManager/packages.d.ts.map +1 -0
- package/dist/packageManager/packages.js +54 -0
- package/dist/packageManager/workspaces.d.ts +4 -0
- package/dist/packageManager/workspaces.d.ts.map +1 -0
- package/dist/packageManager/workspaces.js +59 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +3 -1
- package/package.json +114 -40
- package/LICENSE +0 -21
- package/dist/build.d.ts +0 -2
- package/dist/build.d.ts.map +0 -1
- package/dist/cjs/auth/authFiles.d.ts +0 -44
- package/dist/cjs/auth/authFiles.d.ts.map +0 -1
- package/dist/cjs/auth/authFiles.js +0 -109
- package/dist/cjs/auth/authTasks.d.ts +0 -49
- package/dist/cjs/auth/authTasks.d.ts.map +0 -1
- package/dist/cjs/auth/authTasks.js +0 -384
- package/dist/cjs/auth/setupHelpers.d.ts +0 -26
- package/dist/cjs/auth/setupHelpers.d.ts.map +0 -1
- package/dist/cjs/auth/setupHelpers.js +0 -141
- package/dist/cjs/index.d.ts +0 -12
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -52
- package/dist/cjs/lib/colors.d.ts +0 -22
- package/dist/cjs/lib/colors.d.ts.map +0 -1
- package/dist/cjs/lib/colors.js +0 -52
- package/dist/cjs/lib/index.d.ts +0 -22
- package/dist/cjs/lib/index.d.ts.map +0 -1
- package/dist/cjs/lib/index.js +0 -146
- package/dist/cjs/lib/installHelpers.d.ts +0 -17
- package/dist/cjs/lib/installHelpers.d.ts.map +0 -1
- package/dist/cjs/lib/installHelpers.js +0 -72
- package/dist/cjs/lib/loadEnvFiles.d.ts +0 -5
- package/dist/cjs/lib/loadEnvFiles.d.ts.map +0 -1
- package/dist/cjs/lib/loadEnvFiles.js +0 -99
- package/dist/cjs/lib/paths.d.ts +0 -6
- package/dist/cjs/lib/paths.d.ts.map +0 -1
- package/dist/cjs/lib/paths.js +0 -42
- package/dist/cjs/lib/project.d.ts +0 -44
- package/dist/cjs/lib/project.d.ts.map +0 -1
- package/dist/cjs/lib/project.js +0 -269
- package/dist/cjs/lib/version.d.ts +0 -17
- package/dist/cjs/lib/version.d.ts.map +0 -1
- package/dist/cjs/lib/version.js +0 -107
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/telemetry/index.d.ts +0 -20
- package/dist/cjs/telemetry/index.d.ts.map +0 -1
- package/dist/cjs/telemetry/index.js +0 -62
- package/dist/index.d.ts +0 -12
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -20
- package/dist/package.json +0 -1
- package/dist/src/auth/__tests__/authFiles.test.d.ts +0 -2
- package/dist/src/auth/__tests__/authFiles.test.d.ts.map +0 -1
- package/dist/src/auth/__tests__/authTasks.test.d.ts +0 -2
- package/dist/src/auth/__tests__/authTasks.test.d.ts.map +0 -1
- package/dist/src/auth/__tests__/mockFsFiles.d.ts +0 -14
- package/dist/src/auth/__tests__/mockFsFiles.d.ts.map +0 -1
- package/dist/src/auth/__tests__/setupHelpers.test.d.ts +0 -2
- package/dist/src/auth/__tests__/setupHelpers.test.d.ts.map +0 -1
- package/dist/src/auth/authFiles.d.ts +0 -44
- package/dist/src/auth/authFiles.d.ts.map +0 -1
- package/dist/src/auth/authTasks.d.ts +0 -49
- package/dist/src/auth/authTasks.d.ts.map +0 -1
- package/dist/src/auth/setupHelpers.d.ts +0 -26
- package/dist/src/auth/setupHelpers.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -12
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/lib/__tests__/index.test.d.ts +0 -2
- package/dist/src/lib/__tests__/index.test.d.ts.map +0 -1
- package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts +0 -2
- package/dist/src/lib/__tests__/loadEnvFiles.test.d.ts.map +0 -1
- package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts +0 -2
- package/dist/src/lib/__tests__/project.addTomlSetting.test.d.ts.map +0 -1
- package/dist/src/lib/__tests__/project.test.d.ts +0 -2
- package/dist/src/lib/__tests__/project.test.d.ts.map +0 -1
- package/dist/src/lib/__tests__/version.test.d.ts +0 -2
- package/dist/src/lib/__tests__/version.test.d.ts.map +0 -1
- package/dist/src/lib/colors.d.ts +0 -22
- package/dist/src/lib/colors.d.ts.map +0 -1
- package/dist/src/lib/index.d.ts +0 -22
- package/dist/src/lib/index.d.ts.map +0 -1
- package/dist/src/lib/installHelpers.d.ts +0 -17
- package/dist/src/lib/installHelpers.d.ts.map +0 -1
- package/dist/src/lib/loadEnvFiles.d.ts +0 -5
- package/dist/src/lib/loadEnvFiles.d.ts.map +0 -1
- package/dist/src/lib/paths.d.ts +0 -6
- package/dist/src/lib/paths.d.ts.map +0 -1
- package/dist/src/lib/project.d.ts +0 -44
- package/dist/src/lib/project.d.ts.map +0 -1
- package/dist/src/lib/version.d.ts +0 -17
- package/dist/src/lib/version.d.ts.map +0 -1
- package/dist/src/telemetry/index.d.ts +0 -20
- package/dist/src/telemetry/index.d.ts.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.mts +0 -3
- package/dist/vitest.config.d.mts.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the formatted install command for the detected package manager.
|
|
3
|
+
*
|
|
4
|
+
* yarn → `yarn install`
|
|
5
|
+
* npm → `npm install`
|
|
6
|
+
* pnpm → `pnpm install`
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatInstallCommand(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a formatted string for running a Cedar CLI command via the detected
|
|
11
|
+
* package manager.
|
|
12
|
+
*
|
|
13
|
+
* npm → `npx cedar <args>`
|
|
14
|
+
* yarn → `yarn cedar <args>`
|
|
15
|
+
* pnpm → `pnpm cedar <args>`
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatCedarCommand(args: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a formatted string for running a package.json script via the
|
|
20
|
+
* detected package manager.
|
|
21
|
+
*
|
|
22
|
+
* npm → `npm run <script>[ -- args]`
|
|
23
|
+
* yarn → `yarn <script> [args]`
|
|
24
|
+
* pnpm → `pnpm <script> [args]`
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatRunScriptCommand(script: string, args?: string[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a formatted string for running a package.json script in a workspace
|
|
29
|
+
* via the detected package manager.
|
|
30
|
+
*
|
|
31
|
+
* yarn → `yarn workspace <workspace> <script> [args]`
|
|
32
|
+
* npm → `npm run <script> -w <workspace>[ -- args]`
|
|
33
|
+
* pnpm → `pnpm <script> --filter <workspace>[-- args]`
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatRunWorkspaceScriptCommand(workspace: string, script: string, args?: string[]): string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a formatted string for running a local binary (from
|
|
38
|
+
* node_modules/.bin) via the detected package manager.
|
|
39
|
+
*
|
|
40
|
+
* yarn → `yarn <bin> [args]` (PnP-safe)
|
|
41
|
+
* npm → `npx <bin> [args]`
|
|
42
|
+
* pnpm → `pnpm exec <bin> [args]`
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatRunBinCommand(bin: string, args?: string[]): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns a formatted string for running a transitive dependency's binary
|
|
47
|
+
* (one not listed directly in the project's package.json, e.g. Prisma) via
|
|
48
|
+
* the detected package manager.
|
|
49
|
+
*
|
|
50
|
+
* yarn → `npx <bin> [args]`
|
|
51
|
+
* npm → `npx <bin> [args]`
|
|
52
|
+
* pnpm → `pnpm exec <bin> [args]`
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatRunTransitiveBinCommand(bin: string, args?: string[]): string;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a formatted string for running a local binary in a workspace context
|
|
57
|
+
* via the detected package manager.
|
|
58
|
+
*
|
|
59
|
+
* yarn → `yarn workspace <workspace> <bin> [args]`
|
|
60
|
+
* npm → `npm exec -w <workspace> -- <bin> [args]`
|
|
61
|
+
* pnpm → `pnpm exec --filter <workspace> <bin> [args]`
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatRunWorkspaceBinCommand(workspace: string, bin: string, args?: string[]): string;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a formatted string for a one-off package execution via the detected
|
|
66
|
+
* package manager.
|
|
67
|
+
*
|
|
68
|
+
* yarn → `yarn dlx <command> [args]`
|
|
69
|
+
* npm → `npx <command> [args]`
|
|
70
|
+
* pnpm → `pnpm dlx <command> [args]`
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatDlxCommand(command: string, args?: string[]): string;
|
|
73
|
+
/**
|
|
74
|
+
* Returns a formatted string for adding packages to the project root via the
|
|
75
|
+
* detected package manager.
|
|
76
|
+
*
|
|
77
|
+
* yarn → `yarn add [-D] <packages>`
|
|
78
|
+
* npm → `npm install [-D] <packages>`
|
|
79
|
+
* pnpm → `pnpm add [-D] <packages>`
|
|
80
|
+
*/
|
|
81
|
+
export declare function formatAddRootPackagesCommand(packages: string[], dev?: boolean): string;
|
|
82
|
+
/**
|
|
83
|
+
* Returns a formatted string for adding packages to a workspace via the
|
|
84
|
+
* detected package manager.
|
|
85
|
+
*
|
|
86
|
+
* yarn → `yarn workspace <workspace> add [-D] <packages>`
|
|
87
|
+
* npm → `npm install [-D] <packages> -w <workspace>`
|
|
88
|
+
* pnpm → `pnpm add [-D] <packages> --filter <workspace>`
|
|
89
|
+
*/
|
|
90
|
+
export declare function formatAddWorkspacePackagesCommand(workspace: string, packages: string[], dev?: boolean): string;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a formatted string for removing packages from a workspace via the
|
|
93
|
+
* detected package manager.
|
|
94
|
+
*
|
|
95
|
+
* yarn → `yarn workspace <workspace> remove <packages>`
|
|
96
|
+
* npm → `npm uninstall <packages> -w <workspace>`
|
|
97
|
+
* pnpm → `pnpm remove <packages> --filter <workspace>`
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatRemoveWorkspacePackagesCommand(workspace: string, packages: string[]): string;
|
|
100
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/packageManager/display.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CASzD;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAgBR;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,CAa5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CASR;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,GAClB,MAAM,CAcR;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,CAS7E;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAAE,EAClB,GAAG,UAAQ,GACV,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,GAAG,UAAQ,GACV,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAcR"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
2
|
+
function formatInstallCommand() {
|
|
3
|
+
return `${getPackageManager()} install`;
|
|
4
|
+
}
|
|
5
|
+
function formatCedarCommand(args) {
|
|
6
|
+
const pm = getPackageManager();
|
|
7
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
8
|
+
if (pm === "npm") {
|
|
9
|
+
return `npx cedar${argStr}`;
|
|
10
|
+
}
|
|
11
|
+
return `${pm} cedar${argStr}`;
|
|
12
|
+
}
|
|
13
|
+
function formatRunScriptCommand(script, args = []) {
|
|
14
|
+
const pm = getPackageManager();
|
|
15
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
16
|
+
if (pm === "npm") {
|
|
17
|
+
const separator = args.length > 0 ? " -- " : "";
|
|
18
|
+
return `npm run ${script}${separator}${args.join(" ")}`;
|
|
19
|
+
}
|
|
20
|
+
return `${pm} ${script}${argStr}`;
|
|
21
|
+
}
|
|
22
|
+
function formatRunWorkspaceScriptCommand(workspace, script, args = []) {
|
|
23
|
+
const pm = getPackageManager();
|
|
24
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
25
|
+
if (pm === "yarn") {
|
|
26
|
+
return `yarn workspace ${workspace} ${script}${argStr}`;
|
|
27
|
+
}
|
|
28
|
+
if (pm === "npm") {
|
|
29
|
+
const separator2 = args.length > 0 ? " -- " : "";
|
|
30
|
+
return `npm run ${script} -w ${workspace}${separator2}${args.join(" ")}`;
|
|
31
|
+
}
|
|
32
|
+
const separator = args.length > 0 ? " -- " : "";
|
|
33
|
+
return `pnpm ${script} --filter ${workspace}${separator}${args.join(" ")}`;
|
|
34
|
+
}
|
|
35
|
+
function formatRunBinCommand(bin, args = []) {
|
|
36
|
+
const pm = getPackageManager();
|
|
37
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
38
|
+
if (pm === "npm") {
|
|
39
|
+
return `npx ${bin}${argStr}`;
|
|
40
|
+
}
|
|
41
|
+
if (pm === "pnpm") {
|
|
42
|
+
return `pnpm exec ${bin}${argStr}`;
|
|
43
|
+
}
|
|
44
|
+
return `yarn ${bin}${argStr}`;
|
|
45
|
+
}
|
|
46
|
+
function formatRunTransitiveBinCommand(bin, args = []) {
|
|
47
|
+
const pm = getPackageManager();
|
|
48
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
49
|
+
if (pm === "pnpm") {
|
|
50
|
+
return `pnpm exec ${bin}${argStr}`;
|
|
51
|
+
}
|
|
52
|
+
return `npx ${bin}${argStr}`;
|
|
53
|
+
}
|
|
54
|
+
function formatRunWorkspaceBinCommand(workspace, bin, args = []) {
|
|
55
|
+
const pm = getPackageManager();
|
|
56
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
57
|
+
if (pm === "yarn") {
|
|
58
|
+
return `yarn workspace ${workspace} ${bin}${argStr}`;
|
|
59
|
+
}
|
|
60
|
+
if (pm === "npm") {
|
|
61
|
+
return `npm exec -w ${workspace} -- ${bin}${argStr}`;
|
|
62
|
+
}
|
|
63
|
+
return `pnpm exec --filter ${workspace} ${bin}${argStr}`;
|
|
64
|
+
}
|
|
65
|
+
function formatDlxCommand(command, args = []) {
|
|
66
|
+
const pm = getPackageManager();
|
|
67
|
+
const argStr = args.length > 0 ? ` ${args.join(" ")}` : "";
|
|
68
|
+
if (pm === "npm") {
|
|
69
|
+
return `npx ${command}${argStr}`;
|
|
70
|
+
}
|
|
71
|
+
return `${pm} dlx ${command}${argStr}`;
|
|
72
|
+
}
|
|
73
|
+
function formatAddRootPackagesCommand(packages, dev = false) {
|
|
74
|
+
const pm = getPackageManager();
|
|
75
|
+
const devFlag = dev ? " -D" : "";
|
|
76
|
+
const pkgStr = packages.join(" ");
|
|
77
|
+
const addCmd = pm === "npm" ? "install" : "add";
|
|
78
|
+
return `${pm} ${addCmd}${devFlag} ${pkgStr}`;
|
|
79
|
+
}
|
|
80
|
+
function formatAddWorkspacePackagesCommand(workspace, packages, dev = false) {
|
|
81
|
+
const pm = getPackageManager();
|
|
82
|
+
const devFlag = dev ? " -D" : "";
|
|
83
|
+
const pkgStr = packages.join(" ");
|
|
84
|
+
if (pm === "yarn") {
|
|
85
|
+
return `yarn workspace ${workspace} add${devFlag} ${pkgStr}`;
|
|
86
|
+
}
|
|
87
|
+
if (pm === "npm") {
|
|
88
|
+
return `npm install${devFlag} ${pkgStr} -w ${workspace}`;
|
|
89
|
+
}
|
|
90
|
+
return `pnpm add${devFlag} ${pkgStr} --filter ${workspace}`;
|
|
91
|
+
}
|
|
92
|
+
function formatRemoveWorkspacePackagesCommand(workspace, packages) {
|
|
93
|
+
const pm = getPackageManager();
|
|
94
|
+
const pkgStr = packages.join(" ");
|
|
95
|
+
if (pm === "yarn") {
|
|
96
|
+
return `yarn workspace ${workspace} remove ${pkgStr}`;
|
|
97
|
+
}
|
|
98
|
+
if (pm === "npm") {
|
|
99
|
+
return `npm uninstall ${pkgStr} -w ${workspace}`;
|
|
100
|
+
}
|
|
101
|
+
return `pnpm remove ${pkgStr} --filter ${workspace}`;
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
formatAddRootPackagesCommand,
|
|
105
|
+
formatAddWorkspacePackagesCommand,
|
|
106
|
+
formatCedarCommand,
|
|
107
|
+
formatDlxCommand,
|
|
108
|
+
formatInstallCommand,
|
|
109
|
+
formatRemoveWorkspacePackagesCommand,
|
|
110
|
+
formatRunBinCommand,
|
|
111
|
+
formatRunScriptCommand,
|
|
112
|
+
formatRunTransitiveBinCommand,
|
|
113
|
+
formatRunWorkspaceBinCommand,
|
|
114
|
+
formatRunWorkspaceScriptCommand
|
|
115
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import type { Options as ExecaOptions, SyncOptions as ExecaSyncOptions } from 'execa';
|
|
3
|
+
/**
|
|
4
|
+
* Run a script defined in package.json "scripts".
|
|
5
|
+
*
|
|
6
|
+
* - yarn: `yarn <script> [args]`
|
|
7
|
+
* - npm: `npm run <script> [-- args]`
|
|
8
|
+
* - pnpm: `pnpm <script> [args]`
|
|
9
|
+
*/
|
|
10
|
+
export declare function runScript(script: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Synchronous variant of {@link runScript}.
|
|
13
|
+
*/
|
|
14
|
+
export declare function runScriptSync(script: string, args?: string[], options?: ExecaSyncOptions): execa.ExecaSyncReturnValue<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Run a script in a workspace.
|
|
17
|
+
*
|
|
18
|
+
* - yarn: `yarn workspace <workspace> <script> [args]`
|
|
19
|
+
* - npm: `npm run <script> -w <workspace> [-- args]`
|
|
20
|
+
* - pnpm: `pnpm <script> --filter <workspace> [-- args]`
|
|
21
|
+
*/
|
|
22
|
+
export declare function runWorkspaceScript(workspace: string, script: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Run a local binary from node_modules/.bin (PnP-safe for Yarn).
|
|
25
|
+
* Does not support running transitive dependencies, like prisma
|
|
26
|
+
*
|
|
27
|
+
* - yarn: `yarn <bin> [args]`
|
|
28
|
+
* - npm: `npx <bin> [args]`
|
|
29
|
+
* - pnpm: `pnpm exec <bin> [args]`
|
|
30
|
+
*/
|
|
31
|
+
export declare function runBin(bin: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
32
|
+
/** Synchronous variant of {@link runBin} */
|
|
33
|
+
export declare function runBinSync(bin: string, args?: string[], options?: ExecaSyncOptions): execa.ExecaSyncReturnValue<string>;
|
|
34
|
+
export declare function runTransitiveBin(bin: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
35
|
+
/** Synchronous variant of {@link runTransitiveBin} */
|
|
36
|
+
export declare function runTransitiveBinSync(bin: string, args?: string[], options?: ExecaSyncOptions): execa.ExecaSyncReturnValue<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Run a local binary in a workspace context.
|
|
39
|
+
*
|
|
40
|
+
* - yarn: `yarn workspace <workspace> <bin> [args]`
|
|
41
|
+
* - npm: `npm exec -w <workspace> -- <bin> [args]`
|
|
42
|
+
* - pnpm: `pnpm exec --filter <workspace> <bin> [args]`
|
|
43
|
+
*/
|
|
44
|
+
export declare function runWorkspaceBin(workspace: string, bin: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
45
|
+
/**
|
|
46
|
+
* One-off package execution (equivalent to `npx`).
|
|
47
|
+
*
|
|
48
|
+
* - yarn: `yarn dlx <command> [args]`
|
|
49
|
+
* - npm: `npx <command> [args]`
|
|
50
|
+
* - pnpm: `pnpm dlx <command> [args]`
|
|
51
|
+
*/
|
|
52
|
+
export declare function dlx(command: string, args?: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns spawn-compatible `[cmd, args]` for running a node script.
|
|
55
|
+
*
|
|
56
|
+
* Yarn PnP requires wrapping node via `yarn node` so module resolution works.
|
|
57
|
+
* npm and pnpm use standard `node_modules`, so running `node <script>`
|
|
58
|
+
* directly is sufficient.
|
|
59
|
+
*
|
|
60
|
+
* - yarn: `yarn node <script>`
|
|
61
|
+
* - npm: `node <script>`
|
|
62
|
+
* - pnpm: `node <script>`
|
|
63
|
+
*/
|
|
64
|
+
export declare function getNodeRunnerArgs(scriptPath: string): [string, string[]];
|
|
65
|
+
/**
|
|
66
|
+
* Run a node script via execa.
|
|
67
|
+
*
|
|
68
|
+
* Yarn PnP requires wrapping node via `yarn node` so module resolution works.
|
|
69
|
+
* npm and pnpm use standard `node_modules`, so running `node <script>`
|
|
70
|
+
* directly is sufficient.
|
|
71
|
+
*
|
|
72
|
+
* - yarn: `yarn node <script>`
|
|
73
|
+
* - npm: `node <script>`
|
|
74
|
+
* - pnpm: `node <script>`
|
|
75
|
+
*/
|
|
76
|
+
export declare function runWithNode(scriptPath: string, options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
77
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/packageManager/exec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EACV,OAAO,IAAI,YAAY,EACvB,WAAW,IAAI,gBAAgB,EAChC,MAAM,OAAO,CAAA;AAId;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCAWvB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,gBAAgB,sCAkB3B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCAsBvB;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCAcvB;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,gBAAgB,sCAc3B;AAYD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCAUvB;AAED,sDAAsD;AACtD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,gBAAgB,sCAU3B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCAcvB;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CACjB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,MAAM,EAAO,EACnB,OAAO,CAAC,EAAE,YAAY,mCASvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAQxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,mCAGrE"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
3
|
+
function runScript(script, args = [], options) {
|
|
4
|
+
const pm = getPackageManager();
|
|
5
|
+
if (pm === "npm") {
|
|
6
|
+
const npmArgs = args.length > 0 ? ["run", script, "--", ...args] : ["run", script];
|
|
7
|
+
return execa(pm, npmArgs, options);
|
|
8
|
+
}
|
|
9
|
+
return execa(pm, [script, ...args], options);
|
|
10
|
+
}
|
|
11
|
+
function runScriptSync(script, args = [], options) {
|
|
12
|
+
const pm = getPackageManager();
|
|
13
|
+
if (pm === "npm") {
|
|
14
|
+
if (script === "run" && args.length === 0) {
|
|
15
|
+
return execa.sync(pm, ["run"], options);
|
|
16
|
+
}
|
|
17
|
+
const npmArgs = args.length > 0 ? ["run", script, "--", ...args] : ["run", script];
|
|
18
|
+
return execa.sync(pm, npmArgs, options);
|
|
19
|
+
}
|
|
20
|
+
return execa.sync(pm, [script, ...args], options);
|
|
21
|
+
}
|
|
22
|
+
function runWorkspaceScript(workspace, script, args = [], options) {
|
|
23
|
+
const pm = getPackageManager();
|
|
24
|
+
if (pm === "yarn") {
|
|
25
|
+
return execa(pm, ["workspace", workspace, script, ...args], options);
|
|
26
|
+
}
|
|
27
|
+
if (pm === "npm") {
|
|
28
|
+
const npmArgs = args.length > 0 ? ["run", script, "-w", workspace, "--", ...args] : ["run", script, "-w", workspace];
|
|
29
|
+
return execa(pm, npmArgs, options);
|
|
30
|
+
}
|
|
31
|
+
const pnpmArgs = args.length > 0 ? [script, "--filter", workspace, "--", ...args] : [script, "--filter", workspace];
|
|
32
|
+
return execa(pm, pnpmArgs, options);
|
|
33
|
+
}
|
|
34
|
+
function runBin(bin, args = [], options) {
|
|
35
|
+
const pm = getPackageManager();
|
|
36
|
+
if (pm === "npm") {
|
|
37
|
+
return execa("npx", [bin, ...args], options);
|
|
38
|
+
}
|
|
39
|
+
if (pm === "pnpm") {
|
|
40
|
+
return execa(pm, ["exec", bin, ...args], options);
|
|
41
|
+
}
|
|
42
|
+
return execa(pm, [bin, ...args], options);
|
|
43
|
+
}
|
|
44
|
+
function runBinSync(bin, args = [], options) {
|
|
45
|
+
const pm = getPackageManager();
|
|
46
|
+
if (pm === "npm") {
|
|
47
|
+
return execa.sync("npx", [bin, ...args], options);
|
|
48
|
+
}
|
|
49
|
+
if (pm === "pnpm") {
|
|
50
|
+
return execa.sync(pm, ["exec", bin, ...args], options);
|
|
51
|
+
}
|
|
52
|
+
return execa.sync(pm, [bin, ...args], options);
|
|
53
|
+
}
|
|
54
|
+
function runTransitiveBin(bin, args = [], options) {
|
|
55
|
+
const pm = getPackageManager();
|
|
56
|
+
if (pm === "pnpm") {
|
|
57
|
+
return execa(pm, ["exec", bin, ...args], options);
|
|
58
|
+
}
|
|
59
|
+
return execa("npx", [bin, ...args], options);
|
|
60
|
+
}
|
|
61
|
+
function runTransitiveBinSync(bin, args = [], options) {
|
|
62
|
+
const pm = getPackageManager();
|
|
63
|
+
if (pm === "pnpm") {
|
|
64
|
+
return execa.sync(pm, ["exec", bin, ...args], options);
|
|
65
|
+
}
|
|
66
|
+
return execa.sync("npx", [bin, ...args], options);
|
|
67
|
+
}
|
|
68
|
+
function runWorkspaceBin(workspace, bin, args = [], options) {
|
|
69
|
+
const pm = getPackageManager();
|
|
70
|
+
if (pm === "yarn") {
|
|
71
|
+
return execa(pm, ["workspace", workspace, bin, ...args], options);
|
|
72
|
+
}
|
|
73
|
+
if (pm === "npm") {
|
|
74
|
+
return execa(pm, ["exec", "-w", workspace, "--", bin, ...args], options);
|
|
75
|
+
}
|
|
76
|
+
return execa(pm, ["exec", "--filter", workspace, bin, ...args], options);
|
|
77
|
+
}
|
|
78
|
+
function dlx(command, args = [], options) {
|
|
79
|
+
const pm = getPackageManager();
|
|
80
|
+
if (pm === "npm") {
|
|
81
|
+
return execa("npx", [command, ...args], options);
|
|
82
|
+
}
|
|
83
|
+
return execa(pm, ["dlx", command, ...args], options);
|
|
84
|
+
}
|
|
85
|
+
function getNodeRunnerArgs(scriptPath) {
|
|
86
|
+
const pm = getPackageManager();
|
|
87
|
+
if (pm === "yarn") {
|
|
88
|
+
return ["yarn", ["node", scriptPath]];
|
|
89
|
+
}
|
|
90
|
+
return ["node", [scriptPath]];
|
|
91
|
+
}
|
|
92
|
+
function runWithNode(scriptPath, options) {
|
|
93
|
+
const [cmd, args] = getNodeRunnerArgs(scriptPath);
|
|
94
|
+
return execa(cmd, args, options);
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
dlx,
|
|
98
|
+
getNodeRunnerArgs,
|
|
99
|
+
runBin,
|
|
100
|
+
runBinSync,
|
|
101
|
+
runScript,
|
|
102
|
+
runScriptSync,
|
|
103
|
+
runTransitiveBin,
|
|
104
|
+
runTransitiveBinSync,
|
|
105
|
+
runWithNode,
|
|
106
|
+
runWorkspaceBin,
|
|
107
|
+
runWorkspaceScript
|
|
108
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function workspacePackageSpecifier(): string;
|
|
2
|
+
export declare function add(): "install" | "add";
|
|
3
|
+
export declare function install(): string;
|
|
4
|
+
export declare function dedupe(): "dedupe" | undefined;
|
|
5
|
+
export declare function dedupeIsSupported(): boolean;
|
|
6
|
+
export declare function installationErrorMessage(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Gets a string suitable for displaying to the user when telling them to run a
|
|
9
|
+
* Cedar bin command, like `yarn cedar upgrade` or
|
|
10
|
+
* `yarn cedar generate page home /`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function prettyPrintCedarCommand(args: string[]): string;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/packageManager/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,yBAAyB,IAAI,MAAM,CAMlD;AAED,wBAAgB,GAAG,sBAGlB;AAED,wBAAgB,OAAO,WAEtB;AAED,wBAAgB,MAAM,yBAMrB;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,wBAAwB,WAYvC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAM9D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
2
|
+
function workspacePackageSpecifier() {
|
|
3
|
+
if (getPackageManager() === "npm") {
|
|
4
|
+
return "*";
|
|
5
|
+
}
|
|
6
|
+
return "workspace:*";
|
|
7
|
+
}
|
|
8
|
+
function add() {
|
|
9
|
+
const pm = getPackageManager();
|
|
10
|
+
return pm === "npm" ? "install" : "add";
|
|
11
|
+
}
|
|
12
|
+
function install() {
|
|
13
|
+
return "install";
|
|
14
|
+
}
|
|
15
|
+
function dedupe() {
|
|
16
|
+
if (getPackageManager() === "yarn") {
|
|
17
|
+
return "dedupe";
|
|
18
|
+
}
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
function dedupeIsSupported() {
|
|
22
|
+
return getPackageManager() === "yarn";
|
|
23
|
+
}
|
|
24
|
+
function installationErrorMessage() {
|
|
25
|
+
if (getPackageManager() === "yarn") {
|
|
26
|
+
return "Could not finish installation. Please run `yarn install` and then `yarn dedupe`, before continuing";
|
|
27
|
+
}
|
|
28
|
+
return `Could not finish installation. Please run \`${getPackageManager()} ${install()}\` before continuing`;
|
|
29
|
+
}
|
|
30
|
+
function prettyPrintCedarCommand(args) {
|
|
31
|
+
const packageManager = getPackageManager();
|
|
32
|
+
const packageManagerBin = packageManager === "npm" ? "npx" : packageManager;
|
|
33
|
+
return `${packageManagerBin} cedar ${args.join(" ")}`;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
add,
|
|
37
|
+
dedupe,
|
|
38
|
+
dedupeIsSupported,
|
|
39
|
+
install,
|
|
40
|
+
installationErrorMessage,
|
|
41
|
+
prettyPrintCedarCommand,
|
|
42
|
+
workspacePackageSpecifier
|
|
43
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import type { Options as ExecaOptions } from 'execa';
|
|
3
|
+
type AddOptions = ExecaOptions & {
|
|
4
|
+
dev?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Add packages to the project root.
|
|
8
|
+
*
|
|
9
|
+
* - yarn: `yarn add [-D] <packages>`
|
|
10
|
+
* - npm: `npm install [-D] <packages>`
|
|
11
|
+
* - pnpm: `pnpm add -w [-D] <packages>`
|
|
12
|
+
*/
|
|
13
|
+
export declare function addRootPackages(packages: string[], options?: AddOptions): execa.ExecaChildProcess<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Add packages to a specific workspace.
|
|
16
|
+
*
|
|
17
|
+
* - yarn: `yarn workspace <workspace> add [-D] <packages>`
|
|
18
|
+
* - npm: `npm install [-D] <packages> -w <workspace>`
|
|
19
|
+
* - pnpm: `pnpm add [-D] <packages> --filter <workspace>`
|
|
20
|
+
*/
|
|
21
|
+
export declare function addWorkspacePackages(workspace: string, packages: string[], options?: AddOptions): execa.ExecaChildProcess<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Remove packages from a specific workspace.
|
|
24
|
+
*
|
|
25
|
+
* - yarn: `yarn workspace <workspace> remove <packages>`
|
|
26
|
+
* - npm: `npm uninstall <packages> -w <workspace>`
|
|
27
|
+
* - pnpm: `pnpm remove <packages> --filter <workspace>`
|
|
28
|
+
*/
|
|
29
|
+
export declare function removeWorkspacePackages(workspace: string, packages: string[], options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Install all project dependencies.
|
|
32
|
+
*
|
|
33
|
+
* - yarn: `yarn install`
|
|
34
|
+
* - npm: `npm install`
|
|
35
|
+
* - pnpm: `pnpm install`
|
|
36
|
+
*/
|
|
37
|
+
export declare function installPackages(options?: ExecaOptions): execa.ExecaChildProcess<string>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=packages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../../src/packageManager/packages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,OAAO,CAAA;AAIpD,KAAK,UAAU,GAAG,YAAY,GAAG;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAElD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,mCAQvE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,UAAU,mCA4BrB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,YAAY,mCAcvB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,YAAY,mCAGrD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
3
|
+
function addRootPackages(packages, options) {
|
|
4
|
+
const pm = getPackageManager();
|
|
5
|
+
const { dev, ...execaOptions } = options ?? {};
|
|
6
|
+
const addCmd = pm === "npm" ? "install" : "add";
|
|
7
|
+
const devFlag = dev ? ["-D"] : [];
|
|
8
|
+
const rootFlag = pm === "pnpm" ? ["-w"] : [];
|
|
9
|
+
return execa(pm, [addCmd, ...rootFlag, ...devFlag, ...packages], execaOptions);
|
|
10
|
+
}
|
|
11
|
+
function addWorkspacePackages(workspace, packages, options) {
|
|
12
|
+
const pm = getPackageManager();
|
|
13
|
+
const { dev, ...execaOptions } = options ?? {};
|
|
14
|
+
const devFlag = dev ? ["-D"] : [];
|
|
15
|
+
if (pm === "yarn") {
|
|
16
|
+
return execa(
|
|
17
|
+
pm,
|
|
18
|
+
["workspace", workspace, "add", ...devFlag, ...packages],
|
|
19
|
+
execaOptions
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (pm === "npm") {
|
|
23
|
+
return execa(
|
|
24
|
+
pm,
|
|
25
|
+
["install", ...devFlag, ...packages, "-w", workspace],
|
|
26
|
+
execaOptions
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return execa(
|
|
30
|
+
pm,
|
|
31
|
+
["add", ...devFlag, ...packages, "--filter", workspace],
|
|
32
|
+
execaOptions
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function removeWorkspacePackages(workspace, packages, options) {
|
|
36
|
+
const pm = getPackageManager();
|
|
37
|
+
if (pm === "yarn") {
|
|
38
|
+
return execa(pm, ["workspace", workspace, "remove", ...packages], options);
|
|
39
|
+
}
|
|
40
|
+
if (pm === "npm") {
|
|
41
|
+
return execa(pm, ["uninstall", ...packages, "-w", workspace], options);
|
|
42
|
+
}
|
|
43
|
+
return execa(pm, ["remove", ...packages, "--filter", workspace], options);
|
|
44
|
+
}
|
|
45
|
+
function installPackages(options) {
|
|
46
|
+
const pm = getPackageManager();
|
|
47
|
+
return execa(pm, ["install"], options);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
addRootPackages,
|
|
51
|
+
addWorkspacePackages,
|
|
52
|
+
installPackages,
|
|
53
|
+
removeWorkspacePackages
|
|
54
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PackageManager } from '@cedarjs/project-config/packageManager';
|
|
2
|
+
export type AddWorkspaceDirResult = 'exists' | 'added';
|
|
3
|
+
export declare function addWorkspaceDir(baseDir: string, packagePath: string, pm: PackageManager): AddWorkspaceDirResult;
|
|
4
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../src/packageManager/workspaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAE5E,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEtD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,cAAc,GACjB,qBAAqB,CAMvB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function addWorkspaceDir(baseDir, packagePath, pm) {
|
|
4
|
+
if (pm === "pnpm") {
|
|
5
|
+
return addPnpmWorkspaceDir(baseDir, packagePath);
|
|
6
|
+
}
|
|
7
|
+
return addPackageJsonWorkspaceDir(baseDir, packagePath);
|
|
8
|
+
}
|
|
9
|
+
function addPnpmWorkspaceDir(baseDir, packagePath) {
|
|
10
|
+
const yamlPath = path.join(baseDir, "pnpm-workspace.yaml");
|
|
11
|
+
if (!fs.existsSync(yamlPath)) {
|
|
12
|
+
throw new Error("Invalid workspace config in " + yamlPath);
|
|
13
|
+
}
|
|
14
|
+
const content = fs.readFileSync(yamlPath, "utf8");
|
|
15
|
+
const packageEntry = ` - ${packagePath}`;
|
|
16
|
+
if (content.includes(packageEntry)) {
|
|
17
|
+
return "exists";
|
|
18
|
+
}
|
|
19
|
+
const match = content.match(/^(packages:[\s\S]*?)(?=^\w|(?![\s\S]))/m);
|
|
20
|
+
if (!match) {
|
|
21
|
+
throw new Error("Invalid workspace config in " + yamlPath);
|
|
22
|
+
}
|
|
23
|
+
const packagesSection = match[1];
|
|
24
|
+
const lines = packagesSection.split("\n");
|
|
25
|
+
const lastPackageLine = lines.map((line, i) => ({ line, i })).filter(({ line }) => line.trimStart().startsWith("- ")).pop();
|
|
26
|
+
if (!lastPackageLine) {
|
|
27
|
+
throw new Error("Invalid workspace config in " + yamlPath);
|
|
28
|
+
}
|
|
29
|
+
const insertAfter = lastPackageLine.i;
|
|
30
|
+
lines.splice(insertAfter + 1, 0, packageEntry);
|
|
31
|
+
const updatedContent = content.replace(packagesSection, lines.join("\n"));
|
|
32
|
+
fs.writeFileSync(yamlPath, updatedContent, "utf8");
|
|
33
|
+
return "added";
|
|
34
|
+
}
|
|
35
|
+
function addPackageJsonWorkspaceDir(baseDir, packagePath) {
|
|
36
|
+
const pkgPath = path.join(baseDir, "package.json");
|
|
37
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
38
|
+
if (!Array.isArray(pkg.workspaces)) {
|
|
39
|
+
throw new Error("Invalid workspace config in " + pkgPath);
|
|
40
|
+
}
|
|
41
|
+
const hasWildcardPackagesWorkspace = pkg.workspaces.includes("packages/*");
|
|
42
|
+
const hasNamedPackagesWorkspace = pkg.workspaces.includes(packagePath);
|
|
43
|
+
const hasOtherNamedPackages = pkg.workspaces.some(
|
|
44
|
+
(workspace) => workspace.startsWith("packages/") && workspace !== packagePath
|
|
45
|
+
);
|
|
46
|
+
if (hasWildcardPackagesWorkspace || hasNamedPackagesWorkspace) {
|
|
47
|
+
return "exists";
|
|
48
|
+
}
|
|
49
|
+
if (hasOtherNamedPackages) {
|
|
50
|
+
pkg.workspaces.push(packagePath);
|
|
51
|
+
} else {
|
|
52
|
+
pkg.workspaces.push("packages/*");
|
|
53
|
+
}
|
|
54
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
55
|
+
return "added";
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
addWorkspaceDir
|
|
59
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAG9D,KAAK,mBAAmB,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAG9D,KAAK,mBAAmB,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAA;CAC1C,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,CAAC,EAAE,IAAI,QAaZ;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,IAAI,QAe3D"}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -5,7 +5,9 @@ function recordTelemetryAttributes(attributes, span) {
|
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
for (const [key, value] of Object.entries(attributes)) {
|
|
8
|
-
|
|
8
|
+
if (value !== void 0) {
|
|
9
|
+
spanToRecord.setAttribute(key, value);
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
function recordTelemetryError(error, span) {
|