@fersonull/create-npm 1.0.0 → 1.0.1

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/dist/cli.js CHANGED
@@ -9,6 +9,7 @@ const fs_1 = require("fs");
9
9
  const utils_1 = require("./utils");
10
10
  const path_1 = __importDefault(require("path"));
11
11
  async function main() {
12
+ credit();
12
13
  const args = process.argv.slice(2);
13
14
  const projectName = args[0];
14
15
  const isWindows = process.platform === "win32";
@@ -140,4 +141,15 @@ async function main() {
140
141
  process.exit(1);
141
142
  }
142
143
  }
144
+ function credit() {
145
+ process.stdout.write("\x1Bc");
146
+ utils_1.log.info(`
147
+
148
+ _____ _____ _____
149
+ │ │ │ _ │ │ by: https://github.com/fersonull
150
+ │ │ │ │ __│ │ │ │
151
+ │_│___│__│ │_│_│_│
152
+
153
+ `);
154
+ }
143
155
  main();
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fersonull/create-npm",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Automated project scaffolding tool",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
7
- "create-npm-pack": "./dist/cli.js"
7
+ "create-npm": "./dist/cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc",
@@ -14,6 +14,11 @@
14
14
  "author": {
15
15
  "name": "Jasfer Monton"
16
16
  },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
17
22
  "license": "MIT",
18
23
  "devDependencies": {
19
24
  "@types/node": "^20.0.0",
package/src/cli.ts DELETED
@@ -1,176 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawnSync } from "child_process";
4
- import { mkdirSync, existsSync, writeFileSync, rmSync } from "fs";
5
- import { log, promptConfirm } from "./utils";
6
- import path from "path";
7
-
8
- async function main() {
9
- const args: string[] = process.argv.slice(2);
10
- const projectName: string = args[0];
11
- const isWindows = process.platform === "win32";
12
-
13
- if (!projectName) {
14
- log.error("Please provide a package name as an argument.");
15
- log.info("Usage: npx create-npm <project-name>");
16
- process.exit(1);
17
- }
18
-
19
- if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
20
- log.error(
21
- "Invalid project name. Use only alphanumeric characters, dashes, and underscores.",
22
- );
23
- process.exit(1);
24
- }
25
-
26
- const projectPath: string = path.resolve(process.cwd(), projectName);
27
- const srcPath = path.join(projectPath, "src");
28
-
29
- if (existsSync(projectPath)) {
30
- log.error("Package with the same name already exists.");
31
- process.exit(1);
32
- }
33
-
34
- try {
35
- mkdirSync(projectPath);
36
- mkdirSync(srcPath);
37
-
38
- const initGit = spawnSync("git", ["init"], {
39
- cwd: projectPath,
40
- encoding: "utf-8",
41
- });
42
-
43
- if (initGit.error || initGit.status !== 0) {
44
- throw new Error(initGit.error?.message);
45
- }
46
-
47
- const packageJsonContent = {
48
- name: projectName,
49
- description: "This developer is lazy to add a description",
50
- keywords: [],
51
- author: "",
52
- version: "1.0.0",
53
- type: "module",
54
- main: "./dist/index.cjs",
55
- module: "./dist/index.js",
56
- types: "./dist/index.d.ts",
57
- exports: {
58
- ".": {
59
- types: "./dist/index.d.ts",
60
- import: "./dist/index.js",
61
- require: "./dist/index.cjs",
62
- },
63
- },
64
- scripts: {
65
- test: "vitest run",
66
- "test:watch": "vitest",
67
- build: "tsup src/index.ts --format cjs,esm --dts --clean",
68
- dev: "tsup src/index.ts --format cjs,esm --watch --dts",
69
- },
70
- files: ["dist", "README.md", "LICENCE"],
71
- devDependencies: {
72
- tsup: "^8.5.1",
73
- typescript: "^5.9.3",
74
- vitest: "^4.0.18",
75
- },
76
- };
77
-
78
- const tsconfigContent = {
79
- compilerOptions: {
80
- target: "ESNext",
81
- module: "NodeNext",
82
- moduleResolution: "NodeNext",
83
- declaration: true,
84
- strict: true,
85
- outDir: "dist",
86
- },
87
- };
88
-
89
- const gitIgnoreContent = `
90
- # Dependencies
91
- node_modules/
92
- .pnpm-store/
93
-
94
- # Build
95
- dist/
96
- build/
97
-
98
- # Environment and Secrets
99
- .env
100
- .env.local
101
- .env.*.local
102
-
103
- # Logs
104
- npm-debug.log*
105
- yarn-debug.log*
106
- yarn-error.log*
107
-
108
- # System Files
109
- .DS_Store
110
- Thumbs.db
111
-
112
- # IDEs
113
- .vscode/
114
- .idea/
115
- *.swp
116
- `;
117
-
118
- writeFileSync(
119
- path.join(projectPath, "package.json"),
120
- JSON.stringify(packageJsonContent, null, 2),
121
- { mode: 0o644 },
122
- );
123
-
124
- writeFileSync(
125
- path.join(projectPath, "tsconfig.json"),
126
- JSON.stringify(tsconfigContent, null, 2),
127
- { mode: 0o644 },
128
- );
129
-
130
- writeFileSync(path.join(projectPath, ".gitignore"), gitIgnoreContent, {
131
- mode: 0o644,
132
- });
133
-
134
- writeFileSync(path.join(srcPath, "index.ts"), ``, { mode: 0o644 });
135
-
136
- log.success(initGit.stdout);
137
-
138
- const shouldInstall = await promptConfirm(
139
- 'Would you like to run "npm install" now?',
140
- );
141
-
142
- const npmCmd = isWindows ? "npm.cmd" : "npm";
143
-
144
- if (shouldInstall) {
145
- const npmInstall = spawnSync(npmCmd, ["install"], {
146
- cwd: projectPath,
147
- stdio: "inherit",
148
- shell: isWindows,
149
- });
150
-
151
- if (npmInstall.status !== 0 || npmInstall.error) {
152
- log.error(
153
- "Dependency installation failed. You can manually install it later.",
154
- );
155
- } else {
156
- log.success("\nDependencies installed successfully.");
157
- }
158
- }
159
-
160
- log.success(`\nProject created at ${projectPath}`);
161
-
162
- console.log("\nNext steps:");
163
- console.log(` cd ${projectName}`);
164
- console.log(" npm run dev\n");
165
- } catch (error) {
166
- log.error(error instanceof Error ? error.message : String(error));
167
-
168
- if (existsSync(projectPath)) {
169
- rmSync(projectPath, { recursive: true, force: true });
170
- }
171
-
172
- process.exit(1);
173
- }
174
- }
175
-
176
- main();
package/src/utils.ts DELETED
@@ -1,38 +0,0 @@
1
- import * as readline from "readline";
2
-
3
- export const log = {
4
- error: (message: string) => {
5
- console.log("\x1b[31m%s\x1b[0m", `Error: ${message}`);
6
- },
7
- success: (message: string) => {
8
- console.log("\x1b[32m%s\x1b[0m", message);
9
- },
10
- info: (message: string) => {
11
- console.log("\x1b[36m%s\x1b[0m", message);
12
- },
13
- };
14
-
15
- export const promptConfirm = (question: string): Promise<boolean> => {
16
- const rl = readline.createInterface({
17
- input: process.stdin,
18
- output: process.stdout,
19
- });
20
-
21
- return new Promise((resolve) => {
22
- const ask = () => {
23
- rl.question(`${question} (Y/n) → `, (answer) => {
24
- const normalized = answer.trim().toLowerCase() || "y";
25
-
26
- if (["y", "yes"].includes(normalized)) {
27
- rl.close();
28
- resolve(true);
29
- } else {
30
- rl.close();
31
- resolve(false);
32
- }
33
- });
34
- };
35
-
36
- ask();
37
- });
38
- };
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "declaration": true,
7
- "strict": true,
8
- "outDir": "dist",
9
- "forceConsistentCasingInFileNames": true
10
- },
11
- "include": ["src/**/*"]
12
- }