cognite-create 0.2.34 → 0.2.36
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/bin/index.js +17 -0
- package/bin/index.test.js +201 -6
- package/package.json +1 -1
- package/templates/src/App.tsx +29 -0
- /package/templates/src/{index.css → App.css} +0 -0
package/bin/index.js
CHANGED
|
@@ -70,6 +70,23 @@ async function main() {
|
|
|
70
70
|
additionalArgs.push("--template", "react-ts");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// Disable rolldown-vite (experimental) by default
|
|
74
|
+
const hasRolldownFlag = additionalArgs.some(
|
|
75
|
+
(arg) => arg === "--rolldown" || arg === "--no-rolldown"
|
|
76
|
+
);
|
|
77
|
+
if (!hasRolldownFlag) {
|
|
78
|
+
additionalArgs.push("--no-rolldown");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Skip install and start prompts - we'll install our own dependencies
|
|
82
|
+
const hasSkipInstallFlag = additionalArgs.some(
|
|
83
|
+
(arg) =>
|
|
84
|
+
arg === "--skip-install" || arg === "--install" || arg === "--no-install"
|
|
85
|
+
);
|
|
86
|
+
if (!hasSkipInstallFlag) {
|
|
87
|
+
additionalArgs.push("--skip-install");
|
|
88
|
+
}
|
|
89
|
+
|
|
73
90
|
const createArgs = ["create-vite@latest", projectDir, ...additionalArgs];
|
|
74
91
|
await runCreateVite(createArgs);
|
|
75
92
|
await addCogniteTemplates(projectDir);
|
package/bin/index.test.js
CHANGED
|
@@ -135,6 +135,180 @@ describe("CLI Command Tests", () => {
|
|
|
135
135
|
]);
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
it("should add --no-rolldown and --skip-install flags by default", () => {
|
|
139
|
+
const args = ["my-project"];
|
|
140
|
+
let projectDir;
|
|
141
|
+
let additionalArgs = [];
|
|
142
|
+
|
|
143
|
+
if (args.length === 0 || args[0].startsWith("-")) {
|
|
144
|
+
additionalArgs = args;
|
|
145
|
+
} else {
|
|
146
|
+
projectDir = args[0];
|
|
147
|
+
additionalArgs = args.slice(1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Add default template if not specified
|
|
151
|
+
const hasTemplate = additionalArgs.some(
|
|
152
|
+
(arg) => arg === "--template" || arg === "-t"
|
|
153
|
+
);
|
|
154
|
+
if (!hasTemplate) {
|
|
155
|
+
additionalArgs.push("--template", "react-ts");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Disable rolldown-vite (experimental) by default
|
|
159
|
+
const hasRolldownFlag = additionalArgs.some(
|
|
160
|
+
(arg) => arg === "--rolldown" || arg === "--no-rolldown"
|
|
161
|
+
);
|
|
162
|
+
if (!hasRolldownFlag) {
|
|
163
|
+
additionalArgs.push("--no-rolldown");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Skip install and start prompts - we'll install our own dependencies
|
|
167
|
+
const hasSkipInstallFlag = additionalArgs.some(
|
|
168
|
+
(arg) =>
|
|
169
|
+
arg === "--skip-install" ||
|
|
170
|
+
arg === "--install" ||
|
|
171
|
+
arg === "--no-install"
|
|
172
|
+
);
|
|
173
|
+
if (!hasSkipInstallFlag) {
|
|
174
|
+
additionalArgs.push("--skip-install");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const createArgs = ["create-vite@latest", projectDir, ...additionalArgs];
|
|
178
|
+
|
|
179
|
+
expect(projectDir).toBe("my-project");
|
|
180
|
+
expect(additionalArgs).toEqual([
|
|
181
|
+
"--template",
|
|
182
|
+
"react-ts",
|
|
183
|
+
"--no-rolldown",
|
|
184
|
+
"--skip-install",
|
|
185
|
+
]);
|
|
186
|
+
expect(createArgs).toEqual([
|
|
187
|
+
"create-vite@latest",
|
|
188
|
+
"my-project",
|
|
189
|
+
"--template",
|
|
190
|
+
"react-ts",
|
|
191
|
+
"--no-rolldown",
|
|
192
|
+
"--skip-install",
|
|
193
|
+
]);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("should not add --no-rolldown if --rolldown is already specified", () => {
|
|
197
|
+
const args = ["my-project", "--rolldown"];
|
|
198
|
+
let projectDir;
|
|
199
|
+
let additionalArgs = [];
|
|
200
|
+
|
|
201
|
+
if (args.length === 0 || args[0].startsWith("-")) {
|
|
202
|
+
additionalArgs = args;
|
|
203
|
+
} else {
|
|
204
|
+
projectDir = args[0];
|
|
205
|
+
additionalArgs = args.slice(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Add default template if not specified
|
|
209
|
+
const hasTemplate = additionalArgs.some(
|
|
210
|
+
(arg) => arg === "--template" || arg === "-t"
|
|
211
|
+
);
|
|
212
|
+
if (!hasTemplate) {
|
|
213
|
+
additionalArgs.push("--template", "react-ts");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Disable rolldown-vite (experimental) by default
|
|
217
|
+
const hasRolldownFlag = additionalArgs.some(
|
|
218
|
+
(arg) => arg === "--rolldown" || arg === "--no-rolldown"
|
|
219
|
+
);
|
|
220
|
+
if (!hasRolldownFlag) {
|
|
221
|
+
additionalArgs.push("--no-rolldown");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Skip install and start prompts
|
|
225
|
+
const hasSkipInstallFlag = additionalArgs.some(
|
|
226
|
+
(arg) =>
|
|
227
|
+
arg === "--skip-install" ||
|
|
228
|
+
arg === "--install" ||
|
|
229
|
+
arg === "--no-install"
|
|
230
|
+
);
|
|
231
|
+
if (!hasSkipInstallFlag) {
|
|
232
|
+
additionalArgs.push("--skip-install");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const createArgs = ["create-vite@latest", projectDir, ...additionalArgs];
|
|
236
|
+
|
|
237
|
+
expect(projectDir).toBe("my-project");
|
|
238
|
+
expect(additionalArgs).toEqual([
|
|
239
|
+
"--rolldown",
|
|
240
|
+
"--template",
|
|
241
|
+
"react-ts",
|
|
242
|
+
"--skip-install",
|
|
243
|
+
]);
|
|
244
|
+
expect(createArgs).toEqual([
|
|
245
|
+
"create-vite@latest",
|
|
246
|
+
"my-project",
|
|
247
|
+
"--rolldown",
|
|
248
|
+
"--template",
|
|
249
|
+
"react-ts",
|
|
250
|
+
"--skip-install",
|
|
251
|
+
]);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("should not add --no-rolldown if --no-rolldown is already specified", () => {
|
|
255
|
+
const args = ["my-project", "--no-rolldown"];
|
|
256
|
+
let projectDir;
|
|
257
|
+
let additionalArgs = [];
|
|
258
|
+
|
|
259
|
+
if (args.length === 0 || args[0].startsWith("-")) {
|
|
260
|
+
additionalArgs = args;
|
|
261
|
+
} else {
|
|
262
|
+
projectDir = args[0];
|
|
263
|
+
additionalArgs = args.slice(1);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Add default template if not specified
|
|
267
|
+
const hasTemplate = additionalArgs.some(
|
|
268
|
+
(arg) => arg === "--template" || arg === "-t"
|
|
269
|
+
);
|
|
270
|
+
if (!hasTemplate) {
|
|
271
|
+
additionalArgs.push("--template", "react-ts");
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Disable rolldown-vite (experimental) by default
|
|
275
|
+
const hasRolldownFlag = additionalArgs.some(
|
|
276
|
+
(arg) => arg === "--rolldown" || arg === "--no-rolldown"
|
|
277
|
+
);
|
|
278
|
+
if (!hasRolldownFlag) {
|
|
279
|
+
additionalArgs.push("--no-rolldown");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Skip install and start prompts
|
|
283
|
+
const hasSkipInstallFlag = additionalArgs.some(
|
|
284
|
+
(arg) =>
|
|
285
|
+
arg === "--skip-install" ||
|
|
286
|
+
arg === "--install" ||
|
|
287
|
+
arg === "--no-install"
|
|
288
|
+
);
|
|
289
|
+
if (!hasSkipInstallFlag) {
|
|
290
|
+
additionalArgs.push("--skip-install");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const createArgs = ["create-vite@latest", projectDir, ...additionalArgs];
|
|
294
|
+
|
|
295
|
+
expect(projectDir).toBe("my-project");
|
|
296
|
+
expect(additionalArgs).toEqual([
|
|
297
|
+
"--no-rolldown",
|
|
298
|
+
"--template",
|
|
299
|
+
"react-ts",
|
|
300
|
+
"--skip-install",
|
|
301
|
+
]);
|
|
302
|
+
expect(createArgs).toEqual([
|
|
303
|
+
"create-vite@latest",
|
|
304
|
+
"my-project",
|
|
305
|
+
"--no-rolldown",
|
|
306
|
+
"--template",
|
|
307
|
+
"react-ts",
|
|
308
|
+
"--skip-install",
|
|
309
|
+
]);
|
|
310
|
+
});
|
|
311
|
+
|
|
138
312
|
it("should handle flags-only arguments (requires prompt)", () => {
|
|
139
313
|
const args = ["--template", "react-ts"];
|
|
140
314
|
let projectDir;
|
|
@@ -250,13 +424,25 @@ describe("CLI Command Tests", () => {
|
|
|
250
424
|
|
|
251
425
|
switch (packageManager) {
|
|
252
426
|
case "npm":
|
|
253
|
-
return {
|
|
427
|
+
return {
|
|
428
|
+
command: normalized,
|
|
429
|
+
args: ["install", ...devFlag, ...dependencySpecs],
|
|
430
|
+
};
|
|
254
431
|
case "pnpm":
|
|
255
|
-
return {
|
|
432
|
+
return {
|
|
433
|
+
command: normalized,
|
|
434
|
+
args: ["add", ...devFlag, ...dependencySpecs],
|
|
435
|
+
};
|
|
256
436
|
case "yarn":
|
|
257
|
-
return {
|
|
437
|
+
return {
|
|
438
|
+
command: normalized,
|
|
439
|
+
args: ["add", ...devFlag, ...dependencySpecs],
|
|
440
|
+
};
|
|
258
441
|
case "bun":
|
|
259
|
-
return {
|
|
442
|
+
return {
|
|
443
|
+
command: normalized,
|
|
444
|
+
args: ["add", ...devFlag, ...dependencySpecs],
|
|
445
|
+
};
|
|
260
446
|
default:
|
|
261
447
|
return { command: null, args: [] };
|
|
262
448
|
}
|
|
@@ -268,8 +454,17 @@ describe("CLI Command Tests", () => {
|
|
|
268
454
|
});
|
|
269
455
|
|
|
270
456
|
it("should generate correct npm install command for dev dependencies", () => {
|
|
271
|
-
const result = getInstallCommand(
|
|
272
|
-
|
|
457
|
+
const result = getInstallCommand(
|
|
458
|
+
"npm",
|
|
459
|
+
["package-a@1.0.0", "package-b"],
|
|
460
|
+
true
|
|
461
|
+
);
|
|
462
|
+
expect(result.args).toEqual([
|
|
463
|
+
"install",
|
|
464
|
+
"-D",
|
|
465
|
+
"package-a@1.0.0",
|
|
466
|
+
"package-b",
|
|
467
|
+
]);
|
|
273
468
|
});
|
|
274
469
|
|
|
275
470
|
it("should generate correct pnpm add command", () => {
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "./App.css";
|
|
2
|
+
|
|
3
|
+
function App() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="min-h-screen bg-linear-to-br from-blue-50 to-indigo-100 flex items-center justify-center">
|
|
6
|
+
<div className="text-center px-8">
|
|
7
|
+
<h1 className="text-6xl md:text-8xl font-bold text-gray-900 mb-8">
|
|
8
|
+
Welcome to{" "}
|
|
9
|
+
<span className="text-transparent bg-clip-text bg-linear-to-r from-blue-600 to-indigo-600">
|
|
10
|
+
Cognite
|
|
11
|
+
</span>
|
|
12
|
+
</h1>
|
|
13
|
+
<p className="text-2xl text-gray-600 mb-12 max-w-4xl mx-auto">
|
|
14
|
+
Build powerful industrial applications with Cognite Data Fusion
|
|
15
|
+
</p>
|
|
16
|
+
<a
|
|
17
|
+
href="https://refactored-couscous-5l9mkl3.pages.github.io"
|
|
18
|
+
target="_blank"
|
|
19
|
+
rel="noopener noreferrer"
|
|
20
|
+
className="inline-block bg-blue-600 text-white text-xl px-12 py-4 rounded-lg font-semibold hover:bg-blue-700 transition-colors shadow-lg"
|
|
21
|
+
>
|
|
22
|
+
View Documentation →
|
|
23
|
+
</a>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default App;
|
|
File without changes
|