pm-auto 1.0.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/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/build_command.d.ts +7 -0
- package/dist/build_command.d.ts.map +1 -0
- package/dist/build_command.js +97 -0
- package/dist/build_command.js.map +1 -0
- package/dist/config_path.d.ts +4 -0
- package/dist/config_path.d.ts.map +1 -0
- package/dist/config_path.js +43 -0
- package/dist/config_path.js.map +1 -0
- package/dist/config_reader.d.ts +13 -0
- package/dist/config_reader.d.ts.map +1 -0
- package/dist/config_reader.js +96 -0
- package/dist/config_reader.js.map +1 -0
- package/dist/display.d.ts +8 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +29 -0
- package/dist/display.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +6 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +38 -0
- package/dist/install.js.map +1 -0
- package/dist/orchestrator.d.ts +2 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +48 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/nodemon.json +6 -0
- package/package.json +38 -0
- package/src/build_command.ts +119 -0
- package/src/config_path.ts +54 -0
- package/src/config_reader.ts +119 -0
- package/src/display.ts +33 -0
- package/src/index.ts +45 -0
- package/src/install.ts +40 -0
- package/src/orchestrator.ts +71 -0
- package/src/types/index.ts +16 -0
- package/test.json +83 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { buildCommands, buildUninstallCommands } from "./build_command.js";
|
|
2
|
+
import { getConfigObject } from "./config_reader.js";
|
|
3
|
+
import { display } from "./display.js";
|
|
4
|
+
import { install } from "./install.js";
|
|
5
|
+
import type { ConfigType } from "./types/index.js";
|
|
6
|
+
|
|
7
|
+
//Check if the value is an array of ConfigType objects
|
|
8
|
+
function isConfigTypeArray(value: unknown): value is ConfigType[] {
|
|
9
|
+
return (
|
|
10
|
+
Array.isArray(value) &&
|
|
11
|
+
value.every(
|
|
12
|
+
(item) =>
|
|
13
|
+
typeof item === "object" &&
|
|
14
|
+
item !== null &&
|
|
15
|
+
"packages" in item &&
|
|
16
|
+
Array.isArray((item as any).packages),
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const orchestrator = (
|
|
22
|
+
command: string,
|
|
23
|
+
packages: string[],
|
|
24
|
+
options?: any,
|
|
25
|
+
) => {
|
|
26
|
+
if (command === "install") {
|
|
27
|
+
display(
|
|
28
|
+
`Installing packages... ${options.pkgJson ? "from package.json" : (packages as string[]).join(", ")}`,
|
|
29
|
+
"info",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
getConfigObject(packages, options).then(async (config) => {
|
|
33
|
+
if (config.length === 0) {
|
|
34
|
+
display("No configuration found", "error");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isConfigTypeArray(config)) {
|
|
39
|
+
const commands = buildCommands(config);
|
|
40
|
+
await install(commands);
|
|
41
|
+
display("✅ Packages installed successfully", "success");
|
|
42
|
+
process.stdout.write("\x07");
|
|
43
|
+
} else {
|
|
44
|
+
await install(config);
|
|
45
|
+
|
|
46
|
+
display(
|
|
47
|
+
"✅ Packages from package.json installed successfully",
|
|
48
|
+
"success",
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
display(
|
|
54
|
+
`Uninstalling packages... ${(packages as string[]).join(", ")}`,
|
|
55
|
+
"info",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
getConfigObject(packages, options).then(async (config) => {
|
|
59
|
+
if (config.length === 0) {
|
|
60
|
+
display("No configuration found", "error");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isConfigTypeArray(config)) {
|
|
65
|
+
const commands = buildUninstallCommands(config);
|
|
66
|
+
await install(commands);
|
|
67
|
+
display("✅ Packages uninstalled successfully", "success");
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ConfigType {
|
|
2
|
+
name: string;
|
|
3
|
+
packageManager: string;
|
|
4
|
+
packages: { command: string; interactive: boolean }[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface PackageType {
|
|
8
|
+
command: string;
|
|
9
|
+
interactive: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface CommandResult {
|
|
13
|
+
name: string;
|
|
14
|
+
interactive: string[];
|
|
15
|
+
nonInteractive: string[];
|
|
16
|
+
}
|
package/test.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"vite": {
|
|
3
|
+
"name": "vite",
|
|
4
|
+
"packageManager": "npm",
|
|
5
|
+
"packages": [
|
|
6
|
+
{
|
|
7
|
+
"command": "@types/three --save-dev",
|
|
8
|
+
"interactive": false
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"command": "@react-three/fiber",
|
|
12
|
+
"interactive": false
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"command": "gsap",
|
|
16
|
+
"interactive": false
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"command": "create-vite@latest my-app",
|
|
20
|
+
"interactive": true
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
"next": {
|
|
26
|
+
"name": "next",
|
|
27
|
+
"packageManager": "pnpm",
|
|
28
|
+
"packages": [
|
|
29
|
+
{
|
|
30
|
+
"command": "three --save-dev",
|
|
31
|
+
"interactive": false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"command": "@react-three/drei",
|
|
35
|
+
"interactive": false
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"command": "framer-motion",
|
|
39
|
+
"interactive": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"command": "create-next-app@latest my-app",
|
|
43
|
+
"interactive": true
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"test": {
|
|
48
|
+
"name": "test",
|
|
49
|
+
"packageManager": "npm",
|
|
50
|
+
"packages": [
|
|
51
|
+
{
|
|
52
|
+
"command": "three",
|
|
53
|
+
"interactive": false
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"command": "gsap",
|
|
57
|
+
"interactive": false
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"command": "@react-three/fiber",
|
|
61
|
+
"interactive": false
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"test2": {
|
|
66
|
+
"name": "test2",
|
|
67
|
+
"packageManager": "npm",
|
|
68
|
+
"packages": [
|
|
69
|
+
{
|
|
70
|
+
"command": "@react-three/drei",
|
|
71
|
+
"interactive": false
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"command": "framer-motion",
|
|
75
|
+
"interactive": false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"command": "@react-three/postprocessing",
|
|
79
|
+
"interactive": false
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
// For nodejs:
|
|
13
|
+
// "lib": ["esnext"],
|
|
14
|
+
"types": ["node"],
|
|
15
|
+
// and npm install -D @types/node
|
|
16
|
+
|
|
17
|
+
// Other Outputs
|
|
18
|
+
"sourceMap": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": true,
|
|
21
|
+
|
|
22
|
+
// Stricter Typechecking Options
|
|
23
|
+
"noUncheckedIndexedAccess": true,
|
|
24
|
+
"exactOptionalPropertyTypes": true,
|
|
25
|
+
|
|
26
|
+
// Style Options
|
|
27
|
+
// "noImplicitReturns": true,
|
|
28
|
+
// "noImplicitOverride": true,
|
|
29
|
+
// "noUnusedLocals": true,
|
|
30
|
+
// "noUnusedParameters": true,
|
|
31
|
+
// "noFallthroughCasesInSwitch": true,
|
|
32
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
33
|
+
|
|
34
|
+
// Recommended Options
|
|
35
|
+
"strict": true,
|
|
36
|
+
"verbatimModuleSyntax": true,
|
|
37
|
+
"isolatedModules": true,
|
|
38
|
+
"noUncheckedSideEffectImports": true,
|
|
39
|
+
"moduleDetection": "force",
|
|
40
|
+
"skipLibCheck": true
|
|
41
|
+
}
|
|
42
|
+
}
|