pm-auto 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -36
- package/dist/build_command.js +1 -1
- package/dist/build_command.js.map +1 -1
- package/dist/config_path.d.ts +0 -1
- package/dist/config_path.d.ts.map +1 -1
- package/dist/config_path.js +0 -5
- package/dist/config_path.js.map +1 -1
- package/dist/config_reader.d.ts +3 -1
- package/dist/config_reader.d.ts.map +1 -1
- package/dist/config_reader.js +54 -6
- package/dist/config_reader.js.map +1 -1
- package/dist/display.d.ts +5 -2
- package/dist/display.d.ts.map +1 -1
- package/dist/display.js +5 -21
- package/dist/display.js.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +3 -8
- package/dist/install.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +4 -5
- package/dist/orchestrator.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/build_command.ts +119 -119
- package/src/config_path.ts +48 -54
- package/src/config_reader.ts +68 -10
- package/src/display.ts +1 -7
- package/src/index.ts +33 -2
- package/src/install.ts +3 -5
- package/src/orchestrator.ts +5 -6
- package/src/types/index.ts +17 -16
- package/test.json +87 -94
- package/tests/build_command.test.ts +37 -0
- package/tests/config_path.test.ts +120 -0
- package/tests/config_reader.test.ts +179 -0
- package/tests/display.test.ts +83 -0
- package/tests/install.test.ts +200 -0
- package/tsconfig.json +3 -2
- package/vitest.config.js +8 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import { install } from "../src/install.js";
|
|
4
|
+
import * as display from "../src/display.js";
|
|
5
|
+
import type { CommandResult } from "../src/types/index.js";
|
|
6
|
+
|
|
7
|
+
// Mock dependencies
|
|
8
|
+
vi.mock("execa");
|
|
9
|
+
vi.mock("../src/display.js");
|
|
10
|
+
|
|
11
|
+
describe("install", () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
vi.clearAllMocks();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("runs interactive commands with inherit stdio", async () => {
|
|
17
|
+
const commands: CommandResult[] = [
|
|
18
|
+
{
|
|
19
|
+
name: "test",
|
|
20
|
+
interactive: ["npm init"],
|
|
21
|
+
nonInteractive: [],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
26
|
+
|
|
27
|
+
await install(commands);
|
|
28
|
+
|
|
29
|
+
expect(execa).toHaveBeenCalledWith("npm", ["init"], { stdio: "inherit" });
|
|
30
|
+
expect(display.display).toHaveBeenCalledWith(expect.any(String), "info");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("runs non-interactive commands with loading display", async () => {
|
|
34
|
+
const commands: CommandResult[] = [
|
|
35
|
+
{
|
|
36
|
+
name: "test",
|
|
37
|
+
interactive: [],
|
|
38
|
+
nonInteractive: ["npm install react"],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
43
|
+
|
|
44
|
+
await install(commands);
|
|
45
|
+
|
|
46
|
+
expect(display.display).toHaveBeenCalledWith(expect.any(String), "loading");
|
|
47
|
+
expect(execa).toHaveBeenCalledWith("npm", ["install", "react"], {
|
|
48
|
+
stdio: "inherit",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("runs interactive commands before non-interactive", async () => {
|
|
53
|
+
const commands: CommandResult[] = [
|
|
54
|
+
{
|
|
55
|
+
name: "test",
|
|
56
|
+
interactive: ["npm init"],
|
|
57
|
+
nonInteractive: ["npm install"],
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
62
|
+
|
|
63
|
+
await install(commands);
|
|
64
|
+
|
|
65
|
+
// Check interactive was called first
|
|
66
|
+
expect(execa).toHaveBeenNthCalledWith(1, "npm", ["init"], {
|
|
67
|
+
stdio: "inherit",
|
|
68
|
+
});
|
|
69
|
+
expect(execa).toHaveBeenNthCalledWith(2, "npm", ["install"], {
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("handles multiple interactive commands sequentially", async () => {
|
|
75
|
+
const commands: CommandResult[] = [
|
|
76
|
+
{
|
|
77
|
+
name: "test",
|
|
78
|
+
interactive: ["npm init", "npx create-app"],
|
|
79
|
+
nonInteractive: [],
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
84
|
+
|
|
85
|
+
await install(commands);
|
|
86
|
+
|
|
87
|
+
expect(execa).toHaveBeenCalledTimes(2);
|
|
88
|
+
expect(execa).toHaveBeenNthCalledWith(1, "npm", ["init"], {
|
|
89
|
+
stdio: "inherit",
|
|
90
|
+
});
|
|
91
|
+
expect(execa).toHaveBeenNthCalledWith(2, "npx", ["create-app"], {
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("handles command execution errors with stdout", async () => {
|
|
97
|
+
const commands: CommandResult[] = [
|
|
98
|
+
{
|
|
99
|
+
name: "test",
|
|
100
|
+
interactive: [],
|
|
101
|
+
nonInteractive: ["npm install"],
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const error = new Error("Command failed");
|
|
106
|
+
(error as any).stdout = "stdout output";
|
|
107
|
+
(error as any).stderr = "stderr output";
|
|
108
|
+
|
|
109
|
+
vi.mocked(execa).mockRejectedValue(error);
|
|
110
|
+
|
|
111
|
+
await install(commands);
|
|
112
|
+
|
|
113
|
+
expect(display.display).toHaveBeenCalledWith("stdout output", "");
|
|
114
|
+
expect(display.display).toHaveBeenCalledWith("stderr output", "error");
|
|
115
|
+
expect(display.display).toHaveBeenCalledWith(
|
|
116
|
+
expect.stringContaining("Command failed"),
|
|
117
|
+
"error",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("handles command execution errors without stdout/stderr", async () => {
|
|
122
|
+
const commands: CommandResult[] = [
|
|
123
|
+
{
|
|
124
|
+
name: "test",
|
|
125
|
+
interactive: [],
|
|
126
|
+
nonInteractive: ["npm install"],
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
vi.mocked(execa).mockRejectedValue(new Error("Command failed"));
|
|
131
|
+
|
|
132
|
+
await install(commands);
|
|
133
|
+
|
|
134
|
+
expect(display.display).toHaveBeenCalledWith(
|
|
135
|
+
expect.stringContaining("Command failed"),
|
|
136
|
+
"error",
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("processes multiple CommandResult items in sequence", async () => {
|
|
141
|
+
const commands: CommandResult[] = [
|
|
142
|
+
{
|
|
143
|
+
name: "react",
|
|
144
|
+
interactive: [],
|
|
145
|
+
nonInteractive: ["npm install react"],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "vue",
|
|
149
|
+
interactive: [],
|
|
150
|
+
nonInteractive: ["npm install vue"],
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
155
|
+
|
|
156
|
+
await install(commands);
|
|
157
|
+
|
|
158
|
+
expect(execa).toHaveBeenCalledTimes(2);
|
|
159
|
+
expect(execa).toHaveBeenCalledWith("npm", ["install", "react"], {
|
|
160
|
+
stdio: "inherit",
|
|
161
|
+
});
|
|
162
|
+
expect(execa).toHaveBeenCalledWith("npm", ["install", "vue"], {
|
|
163
|
+
stdio: "inherit",
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("handles empty command arrays", async () => {
|
|
168
|
+
const commands: CommandResult[] = [
|
|
169
|
+
{
|
|
170
|
+
name: "test",
|
|
171
|
+
interactive: [],
|
|
172
|
+
nonInteractive: [],
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
|
|
176
|
+
await install(commands);
|
|
177
|
+
|
|
178
|
+
expect(execa).not.toHaveBeenCalled();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("splits command string correctly with multiple args", async () => {
|
|
182
|
+
const commands: CommandResult[] = [
|
|
183
|
+
{
|
|
184
|
+
name: "test",
|
|
185
|
+
interactive: [],
|
|
186
|
+
nonInteractive: ["npm install react --save-dev"],
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
vi.mocked(execa).mockResolvedValue({} as any);
|
|
191
|
+
|
|
192
|
+
await install(commands);
|
|
193
|
+
|
|
194
|
+
expect(execa).toHaveBeenCalledWith(
|
|
195
|
+
"npm",
|
|
196
|
+
["install", "react", "--save-dev"],
|
|
197
|
+
{ stdio: "inherit" },
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
// File Layout
|
|
5
|
-
"rootDir": "./src",
|
|
6
5
|
"outDir": "./dist",
|
|
7
6
|
|
|
8
7
|
// Environment Settings
|
|
@@ -38,5 +37,7 @@
|
|
|
38
37
|
"noUncheckedSideEffectImports": true,
|
|
39
38
|
"moduleDetection": "force",
|
|
40
39
|
"skipLibCheck": true
|
|
41
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"include": ["src/**/*"],
|
|
42
|
+
"exclude": ["node_modules", "dist", "tests/**/*"]
|
|
42
43
|
}
|