create-druid-ui 2.0.0 → 2.1.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/bin/create.js +22 -17
- package/package.json +1 -1
- package/src/index.ts +16 -17
package/bin/create.js
CHANGED
|
@@ -4,34 +4,39 @@
|
|
|
4
4
|
import { downloadTemplate } from "giget";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { execSync } from "node:child_process";
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var args = process.argv.slice(2);
|
|
8
|
+
var projectName = args.find((arg) => !arg.startsWith("-"));
|
|
9
|
+
var templateFlag = args.indexOf("-t") !== -1 ? args.indexOf("-t") : args.indexOf("--template");
|
|
10
|
+
var template = templateFlag !== -1 ? args[templateFlag + 1] : "starter";
|
|
9
11
|
if (!projectName) {
|
|
10
|
-
console.
|
|
12
|
+
console.log("Usage: create-druid-ui <project-name> [-t template]");
|
|
13
|
+
console.log(
|
|
14
|
+
"Templates: starter (default), starter-component, simple, simple-extended"
|
|
15
|
+
);
|
|
11
16
|
process.exit(1);
|
|
12
17
|
}
|
|
13
|
-
var projectDir =
|
|
18
|
+
var projectDir = resolve(projectName);
|
|
14
19
|
async function main() {
|
|
15
|
-
console.log(`Creating
|
|
16
|
-
await downloadTemplate(
|
|
20
|
+
console.log(`Creating "${projectName}" with template "${template}"...`);
|
|
21
|
+
await downloadTemplate(`gh:highcard-dev/druid-ui/examples/${template}`, {
|
|
17
22
|
dir: projectDir,
|
|
18
23
|
force: false
|
|
19
24
|
});
|
|
20
|
-
console.log("Project files created.");
|
|
21
25
|
console.log("Installing dependencies...");
|
|
22
26
|
try {
|
|
23
27
|
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
24
|
-
console.log(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.log("");
|
|
28
|
+
console.log(`
|
|
29
|
+
Done! Run:
|
|
30
|
+
cd ${projectName}
|
|
31
|
+
npm run dev
|
|
32
|
+
`);
|
|
30
33
|
} catch {
|
|
31
|
-
console.error(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
console.error(
|
|
35
|
+
`
|
|
36
|
+
npm install failed. Run manually:
|
|
37
|
+
cd ${projectName} && npm install
|
|
38
|
+
`
|
|
39
|
+
);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
main().catch(console.error);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,40 +4,39 @@ import { downloadTemplate } from "giget";
|
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { execSync } from "node:child_process";
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const projectName = args.find((arg) => !arg.startsWith("-"));
|
|
9
|
+
const templateFlag =
|
|
10
|
+
args.indexOf("-t") !== -1 ? args.indexOf("-t") : args.indexOf("--template");
|
|
11
|
+
const template = templateFlag !== -1 ? args[templateFlag + 1] : "starter";
|
|
9
12
|
|
|
10
13
|
if (!projectName) {
|
|
11
|
-
console.
|
|
14
|
+
console.log("Usage: create-druid-ui <project-name> [-t template]");
|
|
15
|
+
console.log(
|
|
16
|
+
"Templates: starter (default), starter-component, simple, simple-extended",
|
|
17
|
+
);
|
|
12
18
|
process.exit(1);
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
const projectDir =
|
|
21
|
+
const projectDir = resolve(projectName);
|
|
16
22
|
|
|
17
23
|
async function main() {
|
|
18
|
-
console.log(`Creating
|
|
24
|
+
console.log(`Creating "${projectName}" with template "${template}"...`);
|
|
19
25
|
|
|
20
|
-
await downloadTemplate(
|
|
26
|
+
await downloadTemplate(`gh:highcard-dev/druid-ui/examples/${template}`, {
|
|
21
27
|
dir: projectDir,
|
|
22
28
|
force: false,
|
|
23
29
|
});
|
|
24
30
|
|
|
25
|
-
console.log("Project files created.");
|
|
26
31
|
console.log("Installing dependencies...");
|
|
27
32
|
|
|
28
33
|
try {
|
|
29
34
|
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
30
|
-
console.log(
|
|
31
|
-
console.log("Done! To get started:");
|
|
32
|
-
console.log("");
|
|
33
|
-
console.log(` cd ${projectName}`);
|
|
34
|
-
console.log(" npm run dev");
|
|
35
|
-
console.log("");
|
|
35
|
+
console.log(`\nDone! Run:\n cd ${projectName}\n npm run dev\n`);
|
|
36
36
|
} catch {
|
|
37
|
-
console.error(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
console.error("");
|
|
37
|
+
console.error(
|
|
38
|
+
`\nnpm install failed. Run manually:\n cd ${projectName} && npm install\n`,
|
|
39
|
+
);
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|