create-druid-ui 1.7.2-next.2 → 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 +33 -61
- package/package.json +9 -3
- package/src/index.ts +29 -67
package/bin/create.js
CHANGED
|
@@ -1,70 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { downloadTemplate } from "giget";
|
|
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 =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
var projectDir = resolve(projectName);
|
|
19
|
+
async function main() {
|
|
20
|
+
console.log(`Creating "${projectName}" with template "${template}"...`);
|
|
21
|
+
await downloadTemplate(`gh:highcard-dev/druid-ui/examples/${template}`, {
|
|
22
|
+
dir: projectDir,
|
|
23
|
+
force: false
|
|
24
|
+
});
|
|
25
|
+
console.log("Installing dependencies...");
|
|
26
|
+
try {
|
|
27
|
+
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
28
|
+
console.log(`
|
|
29
|
+
Done! Run:
|
|
30
|
+
cd ${projectName}
|
|
31
|
+
npm run dev
|
|
32
|
+
`);
|
|
33
|
+
} catch {
|
|
34
|
+
console.error(
|
|
35
|
+
`
|
|
36
|
+
npm install failed. Run manually:
|
|
37
|
+
cd ${projectName} && npm install
|
|
38
|
+
`
|
|
39
|
+
);
|
|
27
40
|
}
|
|
28
|
-
};
|
|
29
|
-
writeFileSync(
|
|
30
|
-
join(projectDir, "package.json"),
|
|
31
|
-
JSON.stringify(packageJson, null, " ") + "\n"
|
|
32
|
-
);
|
|
33
|
-
var tsconfig = {
|
|
34
|
-
compilerOptions: {
|
|
35
|
-
target: "ESNext",
|
|
36
|
-
module: "ESNext",
|
|
37
|
-
moduleResolution: "bundler",
|
|
38
|
-
strict: true,
|
|
39
|
-
esModuleInterop: true,
|
|
40
|
-
skipLibCheck: true,
|
|
41
|
-
jsx: "react",
|
|
42
|
-
jsxFactory: "d",
|
|
43
|
-
jsxFragmentFactory: "Fragment",
|
|
44
|
-
outDir: "./dist"
|
|
45
|
-
},
|
|
46
|
-
files: ["node_modules/@druid-ui/component/src/jsx.d.ts"],
|
|
47
|
-
include: ["src/**/*"],
|
|
48
|
-
exclude: ["node_modules"]
|
|
49
|
-
};
|
|
50
|
-
writeFileSync(
|
|
51
|
-
join(projectDir, "tsconfig.json"),
|
|
52
|
-
JSON.stringify(tsconfig, null, " ") + "\n"
|
|
53
|
-
);
|
|
54
|
-
writeFileSync(join(projectDir, "src", "index.tsx"), "");
|
|
55
|
-
console.log("Project files created.");
|
|
56
|
-
console.log("Installing dependencies...");
|
|
57
|
-
try {
|
|
58
|
-
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
59
|
-
console.log("");
|
|
60
|
-
console.log("Done! To get started:");
|
|
61
|
-
console.log("");
|
|
62
|
-
console.log(` cd ${projectName}`);
|
|
63
|
-
console.log(" npm run build");
|
|
64
|
-
console.log("");
|
|
65
|
-
} catch {
|
|
66
|
-
console.error("");
|
|
67
|
-
console.error("npm install failed. You can run it manually:");
|
|
68
|
-
console.error(` cd ${projectName} && npm install`);
|
|
69
|
-
console.error("");
|
|
70
41
|
}
|
|
42
|
+
main().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-druid-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-druid-ui": "./bin/create.js"
|
|
7
7
|
},
|
|
8
|
-
"files": [
|
|
8
|
+
"files": [
|
|
9
|
+
"bin",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
9
12
|
"scripts": {
|
|
10
|
-
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node22 --outfile=bin/create.js"
|
|
13
|
+
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node22 --packages=external --outfile=bin/create.js"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"giget": "^2.0.0"
|
|
11
17
|
},
|
|
12
18
|
"devDependencies": {
|
|
13
19
|
"esbuild": "^0.25.11",
|
package/src/index.ts
CHANGED
|
@@ -1,81 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { downloadTemplate } from "giget";
|
|
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() {
|
|
24
|
+
console.log(`Creating "${projectName}" with template "${template}"...`);
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
await downloadTemplate(`gh:highcard-dev/druid-ui/examples/${template}`, {
|
|
27
|
+
dir: projectDir,
|
|
28
|
+
force: false,
|
|
29
|
+
});
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
name: projectName,
|
|
23
|
-
private: true,
|
|
24
|
-
version: "0.0.0",
|
|
25
|
-
type: "module",
|
|
26
|
-
scripts: {
|
|
27
|
-
build: "druid-ui-build src/index.tsx",
|
|
28
|
-
},
|
|
29
|
-
dependencies: {
|
|
30
|
-
"@druid-ui/component": "next",
|
|
31
|
-
"@druid-ui/build": "next",
|
|
32
|
-
},
|
|
33
|
-
};
|
|
31
|
+
console.log("Installing dependencies...");
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
module: "ESNext",
|
|
44
|
-
moduleResolution: "bundler",
|
|
45
|
-
strict: true,
|
|
46
|
-
esModuleInterop: true,
|
|
47
|
-
skipLibCheck: true,
|
|
48
|
-
jsx: "react",
|
|
49
|
-
jsxFactory: "d",
|
|
50
|
-
jsxFragmentFactory: "Fragment",
|
|
51
|
-
outDir: "./dist",
|
|
52
|
-
},
|
|
53
|
-
files: ["node_modules/@druid-ui/component/src/jsx.d.ts"],
|
|
54
|
-
include: ["src/**/*"],
|
|
55
|
-
exclude: ["node_modules"],
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
writeFileSync(
|
|
59
|
-
join(projectDir, "tsconfig.json"),
|
|
60
|
-
JSON.stringify(tsconfig, null, "\t") + "\n",
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
writeFileSync(join(projectDir, "src", "index.tsx"), "");
|
|
64
|
-
|
|
65
|
-
console.log("Project files created.");
|
|
66
|
-
console.log("Installing dependencies...");
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
70
|
-
console.log("");
|
|
71
|
-
console.log("Done! To get started:");
|
|
72
|
-
console.log("");
|
|
73
|
-
console.log(` cd ${projectName}`);
|
|
74
|
-
console.log(" npm run build");
|
|
75
|
-
console.log("");
|
|
76
|
-
} catch {
|
|
77
|
-
console.error("");
|
|
78
|
-
console.error("npm install failed. You can run it manually:");
|
|
79
|
-
console.error(` cd ${projectName} && npm install`);
|
|
80
|
-
console.error("");
|
|
33
|
+
try {
|
|
34
|
+
execSync("npm install", { cwd: projectDir, stdio: "inherit" });
|
|
35
|
+
console.log(`\nDone! Run:\n cd ${projectName}\n npm run dev\n`);
|
|
36
|
+
} catch {
|
|
37
|
+
console.error(
|
|
38
|
+
`\nnpm install failed. Run manually:\n cd ${projectName} && npm install\n`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
81
41
|
}
|
|
42
|
+
|
|
43
|
+
main().catch(console.error);
|