@cieloazul310/digital-go-pandacss-cli 0.1.0-beta.10
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.cjs +169 -0
- package/bin/index.js +174 -0
- package/package.json +50 -0
- package/public/components.json +3 -0
- package/public/components.schema.json +28 -0
package/bin/index.cjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/add-snippets.ts
|
|
5
|
+
var import_simple_git = require("simple-git");
|
|
6
|
+
var import_os = require("os");
|
|
7
|
+
var import_fs3 = require("fs");
|
|
8
|
+
var import_path3 = require("path");
|
|
9
|
+
|
|
10
|
+
// src/read-config.ts
|
|
11
|
+
var import_fs = require("fs");
|
|
12
|
+
var import_path = require("path");
|
|
13
|
+
function readConfig(cwd = process.cwd()) {
|
|
14
|
+
const defaultConfig = {
|
|
15
|
+
outDir: "src/components/ui",
|
|
16
|
+
override: true
|
|
17
|
+
};
|
|
18
|
+
const configPath = (0, import_path.join)(cwd, "components.json");
|
|
19
|
+
if (!(0, import_fs.existsSync)(configPath)) {
|
|
20
|
+
return defaultConfig;
|
|
21
|
+
}
|
|
22
|
+
const config = JSON.parse(
|
|
23
|
+
(0, import_fs.readFileSync)(configPath, "utf-8")
|
|
24
|
+
);
|
|
25
|
+
return {
|
|
26
|
+
...defaultConfig,
|
|
27
|
+
...config
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/copy-components.ts
|
|
32
|
+
var import_fs2 = require("fs");
|
|
33
|
+
var import_path2 = require("path");
|
|
34
|
+
function copyComponents({
|
|
35
|
+
templateDir,
|
|
36
|
+
outputDir,
|
|
37
|
+
versionComment,
|
|
38
|
+
override = true
|
|
39
|
+
}) {
|
|
40
|
+
if ((0, import_fs2.existsSync)(outputDir) && !override) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Output directory already exists: ${outputDir}. Use --override to overwrite.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const dirs = (0, import_fs2.readdirSync)(templateDir, { withFileTypes: true });
|
|
46
|
+
for (const dir of dirs) {
|
|
47
|
+
if (dir.isDirectory()) {
|
|
48
|
+
const files = (0, import_fs2.readdirSync)((0, import_path2.join)(templateDir, dir.name), {
|
|
49
|
+
withFileTypes: true
|
|
50
|
+
});
|
|
51
|
+
for (const file of files) {
|
|
52
|
+
if (file.isFile() && file.name.endsWith(".tsx")) {
|
|
53
|
+
const filePath = (0, import_path2.join)(templateDir, dir.name, file.name);
|
|
54
|
+
const content = (0, import_fs2.readFileSync)(filePath, "utf8");
|
|
55
|
+
(0, import_fs2.writeFileSync)(filePath, versionComment + content, "utf8");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
(0, import_fs2.cpSync)(templateDir, outputDir, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/add-snippets.ts
|
|
64
|
+
async function main(args2) {
|
|
65
|
+
const cwd = process.cwd();
|
|
66
|
+
const { outDir, sourceDir, override } = readConfig(cwd);
|
|
67
|
+
const tmpPath = (0, import_path3.join)((0, import_os.tmpdir)(), `digital-go-pandacss-${Date.now()}`);
|
|
68
|
+
let templateDir = void 0;
|
|
69
|
+
let versionComment = void 0;
|
|
70
|
+
if (sourceDir) {
|
|
71
|
+
(0, import_fs3.cpSync)((0, import_path3.join)(cwd, sourceDir), tmpPath, { recursive: true });
|
|
72
|
+
templateDir = tmpPath;
|
|
73
|
+
versionComment = "// Generated from Custom Source Directory\n";
|
|
74
|
+
} else {
|
|
75
|
+
const git = (0, import_simple_git.simpleGit)();
|
|
76
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
77
|
+
const templateSubdir = "components/src";
|
|
78
|
+
await git.clone(repoUrl, tmpPath);
|
|
79
|
+
const repoGit = (0, import_simple_git.simpleGit)(tmpPath);
|
|
80
|
+
const tag = (await repoGit.raw(["describe", "--tags", "--abbrev=0"])).trim();
|
|
81
|
+
const commit = (await repoGit.revparse(["HEAD"])).trim();
|
|
82
|
+
templateDir = (0, import_path3.join)(tmpPath, templateSubdir);
|
|
83
|
+
versionComment = `// Generated from digital-go-design-system-with-panda@${tag} (commit: ${commit})
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
if (!(0, import_fs3.existsSync)(templateDir)) {
|
|
87
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
88
|
+
}
|
|
89
|
+
const outputDir = (0, import_path3.join)(cwd, outDir);
|
|
90
|
+
copyComponents({
|
|
91
|
+
templateDir,
|
|
92
|
+
outputDir,
|
|
93
|
+
override,
|
|
94
|
+
versionComment
|
|
95
|
+
});
|
|
96
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
97
|
+
}
|
|
98
|
+
async function addSnippets(args2) {
|
|
99
|
+
await main(args2).then(() => process.exit(0)).catch((err) => {
|
|
100
|
+
console.error(err);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/update.ts
|
|
106
|
+
var import_simple_git2 = require("simple-git");
|
|
107
|
+
var import_os2 = require("os");
|
|
108
|
+
var import_fs4 = require("fs");
|
|
109
|
+
var import_path4 = require("path");
|
|
110
|
+
async function main2(args2) {
|
|
111
|
+
const cwd = process.cwd();
|
|
112
|
+
const { outDir, sourceDir, override } = readConfig(cwd);
|
|
113
|
+
let templateDir = sourceDir ? (0, import_path4.join)(cwd, sourceDir) : void 0;
|
|
114
|
+
let latestTag = "";
|
|
115
|
+
let latestCommit = "";
|
|
116
|
+
if (!templateDir) {
|
|
117
|
+
const git = (0, import_simple_git2.simpleGit)();
|
|
118
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
119
|
+
const templateSubdir = "components/src";
|
|
120
|
+
const tmpPath = (0, import_path4.join)((0, import_os2.tmpdir)(), `digital-go-pandacss-${Date.now()}`);
|
|
121
|
+
await git.clone(repoUrl, tmpPath);
|
|
122
|
+
const repoGit = (0, import_simple_git2.simpleGit)(tmpPath);
|
|
123
|
+
latestTag = (await repoGit.raw(["describe", "--tags", "--abbrev=0"])).trim();
|
|
124
|
+
latestCommit = (await repoGit.revparse(["HEAD"])).trim();
|
|
125
|
+
templateDir = (0, import_path4.join)(tmpPath, templateSubdir);
|
|
126
|
+
}
|
|
127
|
+
if (!(0, import_fs4.existsSync)(templateDir)) {
|
|
128
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
129
|
+
}
|
|
130
|
+
const outputDir = (0, import_path4.join)(cwd, outDir);
|
|
131
|
+
if (!(0, import_fs4.existsSync)(outputDir)) {
|
|
132
|
+
throw new Error(`Output directory not found: ${outputDir}`);
|
|
133
|
+
}
|
|
134
|
+
const versionComment = latestTag ? `// Generated from digital-go-design-system-with-panda@${latestTag} (commit: ${latestCommit})
|
|
135
|
+
` : "// Generated from Custom Source Directory\n";
|
|
136
|
+
copyComponents({
|
|
137
|
+
templateDir,
|
|
138
|
+
outputDir,
|
|
139
|
+
versionComment,
|
|
140
|
+
override
|
|
141
|
+
});
|
|
142
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
143
|
+
}
|
|
144
|
+
async function updateComponents(args2) {
|
|
145
|
+
await main2(args2).then(() => process.exit(0)).catch((err) => {
|
|
146
|
+
console.error(err);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/index.ts
|
|
152
|
+
var [, , cmd, ...args] = process.argv;
|
|
153
|
+
(async () => {
|
|
154
|
+
switch (cmd) {
|
|
155
|
+
case "add":
|
|
156
|
+
await addSnippets(args);
|
|
157
|
+
break;
|
|
158
|
+
case "update":
|
|
159
|
+
await updateComponents(args);
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
console.log("Usage: digital-go-pandacss <add|update> [options]");
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
process.exit(0);
|
|
166
|
+
})().catch((err) => {
|
|
167
|
+
console.error(err);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
});
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/add-snippets.ts
|
|
4
|
+
import { simpleGit } from "simple-git";
|
|
5
|
+
import { tmpdir } from "os";
|
|
6
|
+
import { cpSync as cpSync2, existsSync as existsSync3 } from "fs";
|
|
7
|
+
import { join as join3 } from "path";
|
|
8
|
+
|
|
9
|
+
// src/read-config.ts
|
|
10
|
+
import { existsSync, readFileSync } from "fs";
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
function readConfig(cwd = process.cwd()) {
|
|
13
|
+
const defaultConfig = {
|
|
14
|
+
outDir: "src/components/ui",
|
|
15
|
+
override: true
|
|
16
|
+
};
|
|
17
|
+
const configPath = join(cwd, "components.json");
|
|
18
|
+
if (!existsSync(configPath)) {
|
|
19
|
+
return defaultConfig;
|
|
20
|
+
}
|
|
21
|
+
const config = JSON.parse(
|
|
22
|
+
readFileSync(configPath, "utf-8")
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
...defaultConfig,
|
|
26
|
+
...config
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/copy-components.ts
|
|
31
|
+
import {
|
|
32
|
+
readdirSync,
|
|
33
|
+
readFileSync as readFileSync2,
|
|
34
|
+
writeFileSync,
|
|
35
|
+
existsSync as existsSync2,
|
|
36
|
+
cpSync
|
|
37
|
+
} from "fs";
|
|
38
|
+
import { join as join2 } from "path";
|
|
39
|
+
function copyComponents({
|
|
40
|
+
templateDir,
|
|
41
|
+
outputDir,
|
|
42
|
+
versionComment,
|
|
43
|
+
override = true
|
|
44
|
+
}) {
|
|
45
|
+
if (existsSync2(outputDir) && !override) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Output directory already exists: ${outputDir}. Use --override to overwrite.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const dirs = readdirSync(templateDir, { withFileTypes: true });
|
|
51
|
+
for (const dir of dirs) {
|
|
52
|
+
if (dir.isDirectory()) {
|
|
53
|
+
const files = readdirSync(join2(templateDir, dir.name), {
|
|
54
|
+
withFileTypes: true
|
|
55
|
+
});
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
if (file.isFile() && file.name.endsWith(".tsx")) {
|
|
58
|
+
const filePath = join2(templateDir, dir.name, file.name);
|
|
59
|
+
const content = readFileSync2(filePath, "utf8");
|
|
60
|
+
writeFileSync(filePath, versionComment + content, "utf8");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
cpSync(templateDir, outputDir, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/add-snippets.ts
|
|
69
|
+
async function main(args2) {
|
|
70
|
+
const cwd = process.cwd();
|
|
71
|
+
const { outDir, sourceDir, override } = readConfig(cwd);
|
|
72
|
+
const tmpPath = join3(tmpdir(), `digital-go-pandacss-${Date.now()}`);
|
|
73
|
+
let templateDir = void 0;
|
|
74
|
+
let versionComment = void 0;
|
|
75
|
+
if (sourceDir) {
|
|
76
|
+
cpSync2(join3(cwd, sourceDir), tmpPath, { recursive: true });
|
|
77
|
+
templateDir = tmpPath;
|
|
78
|
+
versionComment = "// Generated from Custom Source Directory\n";
|
|
79
|
+
} else {
|
|
80
|
+
const git = simpleGit();
|
|
81
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
82
|
+
const templateSubdir = "components/src";
|
|
83
|
+
await git.clone(repoUrl, tmpPath);
|
|
84
|
+
const repoGit = simpleGit(tmpPath);
|
|
85
|
+
const tag = (await repoGit.raw(["describe", "--tags", "--abbrev=0"])).trim();
|
|
86
|
+
const commit = (await repoGit.revparse(["HEAD"])).trim();
|
|
87
|
+
templateDir = join3(tmpPath, templateSubdir);
|
|
88
|
+
versionComment = `// Generated from digital-go-design-system-with-panda@${tag} (commit: ${commit})
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
if (!existsSync3(templateDir)) {
|
|
92
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
93
|
+
}
|
|
94
|
+
const outputDir = join3(cwd, outDir);
|
|
95
|
+
copyComponents({
|
|
96
|
+
templateDir,
|
|
97
|
+
outputDir,
|
|
98
|
+
override,
|
|
99
|
+
versionComment
|
|
100
|
+
});
|
|
101
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
102
|
+
}
|
|
103
|
+
async function addSnippets(args2) {
|
|
104
|
+
await main(args2).then(() => process.exit(0)).catch((err) => {
|
|
105
|
+
console.error(err);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/update.ts
|
|
111
|
+
import { simpleGit as simpleGit2 } from "simple-git";
|
|
112
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
113
|
+
import { existsSync as existsSync4 } from "fs";
|
|
114
|
+
import { join as join4 } from "path";
|
|
115
|
+
async function main2(args2) {
|
|
116
|
+
const cwd = process.cwd();
|
|
117
|
+
const { outDir, sourceDir, override } = readConfig(cwd);
|
|
118
|
+
let templateDir = sourceDir ? join4(cwd, sourceDir) : void 0;
|
|
119
|
+
let latestTag = "";
|
|
120
|
+
let latestCommit = "";
|
|
121
|
+
if (!templateDir) {
|
|
122
|
+
const git = simpleGit2();
|
|
123
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
124
|
+
const templateSubdir = "components/src";
|
|
125
|
+
const tmpPath = join4(tmpdir2(), `digital-go-pandacss-${Date.now()}`);
|
|
126
|
+
await git.clone(repoUrl, tmpPath);
|
|
127
|
+
const repoGit = simpleGit2(tmpPath);
|
|
128
|
+
latestTag = (await repoGit.raw(["describe", "--tags", "--abbrev=0"])).trim();
|
|
129
|
+
latestCommit = (await repoGit.revparse(["HEAD"])).trim();
|
|
130
|
+
templateDir = join4(tmpPath, templateSubdir);
|
|
131
|
+
}
|
|
132
|
+
if (!existsSync4(templateDir)) {
|
|
133
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
134
|
+
}
|
|
135
|
+
const outputDir = join4(cwd, outDir);
|
|
136
|
+
if (!existsSync4(outputDir)) {
|
|
137
|
+
throw new Error(`Output directory not found: ${outputDir}`);
|
|
138
|
+
}
|
|
139
|
+
const versionComment = latestTag ? `// Generated from digital-go-design-system-with-panda@${latestTag} (commit: ${latestCommit})
|
|
140
|
+
` : "// Generated from Custom Source Directory\n";
|
|
141
|
+
copyComponents({
|
|
142
|
+
templateDir,
|
|
143
|
+
outputDir,
|
|
144
|
+
versionComment,
|
|
145
|
+
override
|
|
146
|
+
});
|
|
147
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
148
|
+
}
|
|
149
|
+
async function updateComponents(args2) {
|
|
150
|
+
await main2(args2).then(() => process.exit(0)).catch((err) => {
|
|
151
|
+
console.error(err);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/index.ts
|
|
157
|
+
var [, , cmd, ...args] = process.argv;
|
|
158
|
+
(async () => {
|
|
159
|
+
switch (cmd) {
|
|
160
|
+
case "add":
|
|
161
|
+
await addSnippets(args);
|
|
162
|
+
break;
|
|
163
|
+
case "update":
|
|
164
|
+
await updateComponents(args);
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
console.log("Usage: digital-go-pandacss <add|update> [options]");
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
process.exit(0);
|
|
171
|
+
})().catch((err) => {
|
|
172
|
+
console.error(err);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cieloazul310/digital-go-pandacss-cli",
|
|
3
|
+
"version": "0.1.0-beta.10",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/cieloazul310/digital-go-design-system-with-panda",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "cieloazul310",
|
|
9
|
+
"url": "https://cieloazul310.github.io"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/cieloazul310/digital-go-design-system-with-panda.git",
|
|
14
|
+
"directory": "packages/cli"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"registry": "https://registry.npmjs.org/"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin",
|
|
22
|
+
"public"
|
|
23
|
+
],
|
|
24
|
+
"bin": {
|
|
25
|
+
"digital-go-pandacss": "./bin/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"dev": "npm run build -- --watch",
|
|
30
|
+
"eslint": "eslint src --fix",
|
|
31
|
+
"format": "prettier --parser typescript --write ."
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"simple-git": "^3.28.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@repo/eslint-config": "^0.1.0-beta.5",
|
|
38
|
+
"@repo/typescript-config": "^0.1.0-beta.5",
|
|
39
|
+
"eslint": "^9.32.0",
|
|
40
|
+
"execa": "^9.6.0",
|
|
41
|
+
"tsup": "8.5.0",
|
|
42
|
+
"typescript": "^5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"lint-staged": {
|
|
45
|
+
"**/*.{js,mjs,cjs,tsx,ts,tsx}": [
|
|
46
|
+
"eslint --fix",
|
|
47
|
+
"prettier --parser typescript --write"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "components.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "UI Components",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"components": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the component."
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"outputDir": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The directory where the components will be generated."
|
|
17
|
+
},
|
|
18
|
+
"sourceDir": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The directory where the source files for the components are located."
|
|
21
|
+
},
|
|
22
|
+
"override": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "Whether to override existing files in the output directory."
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": []
|
|
28
|
+
}
|