@ilanalimanjs/open_pack 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/bin/index.js +36 -0
- package/package.json +25 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { downloadTemplate } from 'giget';
|
|
4
|
+
|
|
5
|
+
const TEMPLATE_SOURCE = 'github:DevIlannn/open_pack/Source';
|
|
6
|
+
const NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
7
|
+
|
|
8
|
+
const [projectName] = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
if (!projectName) {
|
|
12
|
+
console.log('Usage: npx open_pack@latest <project-name>');
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!NAME_PATTERN.test(projectName)) {
|
|
18
|
+
console.error('Invalid project name. Use letters, numbers, dot, dash, or underscore.');
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const targetDirectory = path.resolve(process.cwd(), projectName);
|
|
24
|
+
|
|
25
|
+
console.log(`Creating ${projectName} from Open Pack...`);
|
|
26
|
+
await downloadTemplate(TEMPLATE_SOURCE, { dir: targetDirectory });
|
|
27
|
+
|
|
28
|
+
console.log(
|
|
29
|
+
`\nDone. Next steps:\n\n cd ${projectName}\n npm install\n cp .env.examples .env\n node --env-file=.env core/index.js\n`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main().catch((error) => {
|
|
34
|
+
console.error(`Failed to create project: ${error.message}`);
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ilanalimanjs/open_pack",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Open Pack CLI: create a new project from the Open Pack source template",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"open_pack": "bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.11"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/DevIlannn/open_pack.git"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"giget": "^2.0.0"
|
|
24
|
+
}
|
|
25
|
+
}
|