@jrapps/create-cli-tools 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.
- package/README.md +0 -0
- package/bin/create.js +123 -0
- package/package.json +34 -0
package/README.md
ADDED
|
File without changes
|
package/bin/create.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const readline = require('readline');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
8
|
+
|
|
9
|
+
function question(prompt) {
|
|
10
|
+
return new Promise((resolve) => rl.question(prompt, resolve));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function toSlug(str) {
|
|
14
|
+
return str.toLowerCase().trim().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
console.log('\n--- Create New CLI Tools Project Contribution ---\n');
|
|
19
|
+
|
|
20
|
+
const projectName = await question('Project contribution name: ');
|
|
21
|
+
const description = await question('Description: ');
|
|
22
|
+
const author = await question('Author: ');
|
|
23
|
+
const version = await question('Version (1.0.0): ') || '1.0.0';
|
|
24
|
+
rl.close();
|
|
25
|
+
|
|
26
|
+
const slug = toSlug(projectName);
|
|
27
|
+
const targetDir = path.join(process.cwd(), slug);
|
|
28
|
+
|
|
29
|
+
if (fs.existsSync(targetDir)) {
|
|
30
|
+
console.error(`\nError: Directory "${slug}" already exists.\n`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
35
|
+
fs.mkdirSync(path.join(targetDir, 'src'), { recursive: true });
|
|
36
|
+
|
|
37
|
+
// package.json
|
|
38
|
+
const pkg = {
|
|
39
|
+
name: `${slug}`,
|
|
40
|
+
version,
|
|
41
|
+
description,
|
|
42
|
+
license: 'ISC',
|
|
43
|
+
author,
|
|
44
|
+
type: 'commonjs',
|
|
45
|
+
scripts: {
|
|
46
|
+
build: 'clitools build',
|
|
47
|
+
create: 'clitools create',
|
|
48
|
+
test: 'clitools test',
|
|
49
|
+
release: 'clitools release'
|
|
50
|
+
},
|
|
51
|
+
devDependencies: {
|
|
52
|
+
'@types/react': '^19.0.0',
|
|
53
|
+
'@types/react-dom': '^19.0.0',
|
|
54
|
+
'@vitejs/plugin-react': '^4.0.0',
|
|
55
|
+
typescript: '^5.0.0',
|
|
56
|
+
vite: '^6.0.0'
|
|
57
|
+
},
|
|
58
|
+
dependencies: {
|
|
59
|
+
'@jrapps/cli-tools-create': '^0.9.0',
|
|
60
|
+
react: '^19.0.0',
|
|
61
|
+
'react-dom': '^19.0.0',
|
|
62
|
+
'react-to-webcomponent': '^2.0.0'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
path.join(targetDir, 'package.json'),
|
|
68
|
+
JSON.stringify(pkg, null, 2) + '\n',
|
|
69
|
+
'utf8'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// tsconfig.json
|
|
73
|
+
const tsconfig = {
|
|
74
|
+
compilerOptions: {
|
|
75
|
+
target: 'ES2020',
|
|
76
|
+
module: 'ESNext',
|
|
77
|
+
moduleResolution: 'bundler',
|
|
78
|
+
lib: ['ES2020', 'DOM'],
|
|
79
|
+
outDir: './dist',
|
|
80
|
+
rootDir: './src',
|
|
81
|
+
strict: true,
|
|
82
|
+
esModuleInterop: true,
|
|
83
|
+
skipLibCheck: true,
|
|
84
|
+
declaration: true,
|
|
85
|
+
declarationMap: true,
|
|
86
|
+
sourceMap: true,
|
|
87
|
+
jsx: 'react'
|
|
88
|
+
},
|
|
89
|
+
include: ['src/**/*'],
|
|
90
|
+
exclude: ['node_modules', 'dist']
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(
|
|
94
|
+
path.join(targetDir, 'tsconfig.json'),
|
|
95
|
+
JSON.stringify(tsconfig, null, 2) + '\n',
|
|
96
|
+
'utf8'
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// src/tools.ts
|
|
100
|
+
fs.writeFileSync(
|
|
101
|
+
path.join(targetDir, 'src', 'tools.ts'),
|
|
102
|
+
`import { newTool } from '@jrapps/cli-tools-create';\n\nexport default newTool();\n`,
|
|
103
|
+
'utf8'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// README.md
|
|
107
|
+
fs.writeFileSync(
|
|
108
|
+
path.join(targetDir, 'README.md'),
|
|
109
|
+
`# ${projectName}\n\n${description}\n`,
|
|
110
|
+
'utf8'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
console.log(`\nCreated project: ${slug}/`);
|
|
114
|
+
console.log(`\nNext steps:\n`);
|
|
115
|
+
console.log(` cd ${slug}`);
|
|
116
|
+
console.log(` npm install`);
|
|
117
|
+
console.log(` npm run create\n`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
main().catch((err) => {
|
|
121
|
+
console.error(err);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jrapps/create-cli-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Scaffold a new @jrapps/cli-tools project.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Josh Roberts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"bin": {
|
|
9
|
+
"create-cli-tools": "./bin/create.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "clitools build",
|
|
16
|
+
"create": "clitools create",
|
|
17
|
+
"test": "clitools test",
|
|
18
|
+
"release": "clitools release"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/react": "^19.2.15",
|
|
22
|
+
"@types/react-dom": "^19.2.3",
|
|
23
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
24
|
+
"esbuild": "^0.28.0",
|
|
25
|
+
"typescript": "^5.0.0",
|
|
26
|
+
"vite": "^8.0.14"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@jrapps/cli-tools-create": "^0.5.0",
|
|
30
|
+
"react": "^19.2.6",
|
|
31
|
+
"react-dom": "^19.2.6",
|
|
32
|
+
"react-to-webcomponent": "^2.0.1"
|
|
33
|
+
}
|
|
34
|
+
}
|