@pavlos-samaras/react-cli 0.0.0-stage → 1.0.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.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=ct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ct.d.ts","sourceRoot":"","sources":["../../src/bin/ct.ts"],"names":[],"mappings":""}
package/dist/bin/ct.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { Command } from "commander";
5
+ import { generateComponent } from "../utils/generateComponent.js";
6
+ const program = new Command();
7
+ const TYPES = ["component"];
8
+ program.name("ct").description("My React CLI").version("1.0.0");
9
+ program
10
+ .command("generate <type> <name>")
11
+ .alias("g")
12
+ .description("Generate a component, e.g. ct g component Button")
13
+ .option("-d, --dir <div>", "target folder", "src/components")
14
+ .option("--ts", "create a .tsx file")
15
+ .action(async (type, name, options) => {
16
+ if (!TYPES.includes(type))
17
+ return console.log(`Unknown type: ${type}`);
18
+ if (type === "component") {
19
+ const folder = path.join(process.cwd(), options.dir, name);
20
+ fs.mkdirSync(folder, { recursive: true });
21
+ const { file, content } = await generateComponent(name, options);
22
+ fs.writeFileSync(path.join(folder, file), content);
23
+ }
24
+ });
25
+ program.parse();
26
+ //# sourceMappingURL=ct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ct.js","sourceRoot":"","sources":["../../src/bin/ct.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,MAAM,KAAK,GAAG,CAAC,WAAW,CAAC,CAAC;AAE5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhE,OAAO;KACJ,OAAO,CAAC,wBAAwB,CAAC;KACjC,KAAK,CAAC,GAAG,CAAC;KACV,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,CAAC,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,CAAC;KAC5D,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;KACpC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAY,EAAE,OAAyB,EAAE,EAAE;IACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAEvE,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3D,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const buildComponentTemplate: (name: string) => string;
2
+ export default buildComponentTemplate;
3
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/templates/component.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,sBAAsB,SAAU,MAAM,WAI3C,CAAC;eAEa,sBAAsB"}
@@ -0,0 +1,7 @@
1
+ const buildComponentTemplate = (name) => {
2
+ return `export const ${name} = () => {
3
+ return <div></div>
4
+ }`;
5
+ };
6
+ export default buildComponentTemplate;
7
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/templates/component.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC9C,OAAO,gBAAgB,IAAI;;EAE3B,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type ComponentOptions = {
2
+ dir: string;
3
+ ts?: boolean;
4
+ };
5
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { ComponentOptions } from "../types/component.js";
2
+ export declare const generateComponent: (name: string, options: ComponentOptions) => Promise<{
3
+ file: string;
4
+ content: string;
5
+ }>;
6
+ //# sourceMappingURL=generateComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateComponent.d.ts","sourceRoot":"","sources":["../../src/utils/generateComponent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,eAAO,MAAM,iBAAiB,SACtB,MAAM,WACH,gBAAgB;;;EAuB1B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import prompts from "prompts";
2
+ import buildComponentTemplate from "../templates/component.js";
3
+ export const generateComponent = async (name, options) => {
4
+ let useTs = options.ts;
5
+ if (useTs === undefined) {
6
+ const answer = await prompts({
7
+ type: "select",
8
+ name: "ts",
9
+ message: "Use TypeScript?",
10
+ choices: [
11
+ { title: "Yes", value: true },
12
+ { title: "No", value: false },
13
+ ],
14
+ initial: 0,
15
+ });
16
+ useTs = answer.ts ?? false;
17
+ }
18
+ const ext = useTs ? "tsx" : "jsx";
19
+ const content = buildComponentTemplate(name);
20
+ return { file: `${name}.${ext}`, content };
21
+ };
22
+ //# sourceMappingURL=generateComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateComponent.js","sourceRoot":"","sources":["../../src/utils/generateComponent.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAG/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,IAAY,EACZ,OAAyB,EACzB,EAAE;IACF,IAAI,KAAK,GAAG,OAAO,CAAC,EAAE,CAAC;IAEvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC3B,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC7B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;aAC9B;YACD,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,KAAK,GAAG,MAAM,CAAC,EAAE,IAAI,KAAK,CAAC;IAC7B,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAElC,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7C,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@pavlos-samaras/react-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "author": "sammern-stack",
5
+ "description": "A CLI to generate React code",
6
+ "keywords": ["react", "cli", "generator"],
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "bin": {
10
+ "ct": "./dist/bin/ct.js"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "dev": "tsx src/bin/ct.ts",
15
+ "build:link": "npm run build && npm link"
16
+ },
17
+ "dependencies": {
18
+ "commander": "^15.0.0",
19
+ "prompts": "^2.4.2"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^26.6.6",
23
+ "@types/prompts": "^2.4.9",
24
+ "tsx": "^4.23.15",
25
+ "typescript": "^7.0.2"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ]
30
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.