@cieloazul310/digital-go-pandacss-cli 0.1.0-beta.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/bin/add-snippets.cjs +44 -0
- package/bin/add-snippets.js +43 -0
- package/package.json +50 -0
- package/public/components.json +3 -0
- package/public/components.schema.json +28 -0
|
@@ -0,0 +1,44 @@
|
|
|
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_fs = require("fs");
|
|
8
|
+
var import_path = require("path");
|
|
9
|
+
async function main() {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const configPath = (0, import_path.join)(cwd, "components.json");
|
|
12
|
+
let outDir = "src/components/ui";
|
|
13
|
+
let templateDir = void 0;
|
|
14
|
+
let override = true;
|
|
15
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
16
|
+
const config = JSON.parse((0, import_fs.readFileSync)(configPath, "utf-8"));
|
|
17
|
+
outDir = config.outDir ?? outDir;
|
|
18
|
+
templateDir = config.sourceDir ? (0, import_path.join)(cwd, config.sourceDir) : void 0;
|
|
19
|
+
override = config.override ?? override;
|
|
20
|
+
}
|
|
21
|
+
if (!templateDir) {
|
|
22
|
+
const git = (0, import_simple_git.simpleGit)();
|
|
23
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
24
|
+
const templateSubdir = "components/src";
|
|
25
|
+
const tmpPath = (0, import_path.join)((0, import_os.tmpdir)(), `digital-go-pandacss-${Date.now()}`);
|
|
26
|
+
await git.clone(repoUrl, tmpPath);
|
|
27
|
+
templateDir = (0, import_path.join)(tmpPath, templateSubdir);
|
|
28
|
+
}
|
|
29
|
+
if (!(0, import_fs.existsSync)(templateDir)) {
|
|
30
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
31
|
+
}
|
|
32
|
+
const outputDir = (0, import_path.join)(cwd, outDir);
|
|
33
|
+
if ((0, import_fs.existsSync)(outputDir) && !override) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Output directory already exists: ${outputDir}. Use --override to overwrite.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
(0, import_fs.cpSync)(templateDir, outputDir, { recursive: true });
|
|
39
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
40
|
+
}
|
|
41
|
+
main().then(() => process.exit(0)).catch((err) => {
|
|
42
|
+
console.error(err);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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, existsSync, readFileSync } from "fs";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
async function main() {
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
const configPath = join(cwd, "components.json");
|
|
11
|
+
let outDir = "src/components/ui";
|
|
12
|
+
let templateDir = void 0;
|
|
13
|
+
let override = true;
|
|
14
|
+
if (existsSync(configPath)) {
|
|
15
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
16
|
+
outDir = config.outDir ?? outDir;
|
|
17
|
+
templateDir = config.sourceDir ? join(cwd, config.sourceDir) : void 0;
|
|
18
|
+
override = config.override ?? override;
|
|
19
|
+
}
|
|
20
|
+
if (!templateDir) {
|
|
21
|
+
const git = simpleGit();
|
|
22
|
+
const repoUrl = "https://github.com/cieloazul310/digital-go-design-system-with-panda";
|
|
23
|
+
const templateSubdir = "components/src";
|
|
24
|
+
const tmpPath = join(tmpdir(), `digital-go-pandacss-${Date.now()}`);
|
|
25
|
+
await git.clone(repoUrl, tmpPath);
|
|
26
|
+
templateDir = join(tmpPath, templateSubdir);
|
|
27
|
+
}
|
|
28
|
+
if (!existsSync(templateDir)) {
|
|
29
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
30
|
+
}
|
|
31
|
+
const outputDir = join(cwd, outDir);
|
|
32
|
+
if (existsSync(outputDir) && !override) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Output directory already exists: ${outputDir}. Use --override to overwrite.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
cpSync(templateDir, outputDir, { recursive: true });
|
|
38
|
+
console.log(`\u2705 UI components generated from GitHub at ${outDir}`);
|
|
39
|
+
}
|
|
40
|
+
main().then(() => process.exit(0)).catch((err) => {
|
|
41
|
+
console.error(err);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cieloazul310/digital-go-pandacss-cli",
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
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
|
+
"add": "./bin/add-snippets.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.0",
|
|
38
|
+
"@repo/typescript-config": "^0.1.0-beta.0",
|
|
39
|
+
"eslint": "^9.28.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
|
+
}
|