@vidavidorra/create-project 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.
Files changed (40) hide show
  1. package/.editorconfig +12 -0
  2. package/.github/husky/commit-msg +4 -0
  3. package/.github/husky/pre-commit +4 -0
  4. package/.github/lint-staged.js +6 -0
  5. package/.github/renovate.json +4 -0
  6. package/.github/workflows/ci-cd.yml +36 -0
  7. package/.gitignore +355 -0
  8. package/.npmrc +1 -0
  9. package/LICENSE.md +619 -0
  10. package/README.md +76 -0
  11. package/dist/content/ci-cd.d.ts +246 -0
  12. package/dist/content/ci-cd.js +112 -0
  13. package/dist/content/file.d.ts +36 -0
  14. package/dist/content/file.js +52 -0
  15. package/dist/content/files.d.ts +4 -0
  16. package/dist/content/files.js +23 -0
  17. package/dist/content/index.d.ts +1 -0
  18. package/dist/content/index.js +2 -0
  19. package/dist/content/lint-staged.d.ts +12 -0
  20. package/dist/content/lint-staged.js +40 -0
  21. package/dist/content/package.d.ts +211 -0
  22. package/dist/content/package.js +122 -0
  23. package/dist/content/readme/badge.d.ts +15 -0
  24. package/dist/content/readme/badge.js +75 -0
  25. package/dist/content/readme/index.d.ts +1 -0
  26. package/dist/content/readme/index.js +2 -0
  27. package/dist/content/readme/readme.d.ts +17 -0
  28. package/dist/content/readme/readme.js +129 -0
  29. package/dist/content/readme/readme.js.map +1 -0
  30. package/dist/content/readme/readme.test.d.ts +1 -0
  31. package/dist/content/readme/readme.test.js +35 -0
  32. package/dist/content/readme/readme.test.js.map +1 -0
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +62 -0
  35. package/dist/options.d.ts +43 -0
  36. package/dist/options.js +52 -0
  37. package/dist/root-path.d.ts +2 -0
  38. package/dist/root-path.js +5 -0
  39. package/package.json +226 -0
  40. package/tsconfig.json +14 -0
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ import { input, confirm } from '@inquirer/prompts';
2
+ import { schema } from './options.js';
3
+ import { files } from './content/index.js';
4
+ function validate(value, option) {
5
+ const validation = schema.shape[option].safeParse(value);
6
+ return validation.success
7
+ ? true
8
+ : validation.error.errors.map(({ message }) => message).join('\n> ');
9
+ }
10
+ const project = await input({
11
+ message: 'Project name:',
12
+ validate: (value) => validate(value, 'project'),
13
+ });
14
+ const name = project.replaceAll(' ', '-').toLowerCase();
15
+ const defaultPackage = validate(name, 'package') === true ? name : undefined;
16
+ const options = {
17
+ project,
18
+ package: await input({
19
+ message: 'Package name:',
20
+ validate: (value) => validate(value, 'package'),
21
+ default: defaultPackage,
22
+ }),
23
+ public: await confirm({
24
+ message: 'Make package public?',
25
+ default: schema.shape.public._def.defaultValue(),
26
+ }),
27
+ description: await input({
28
+ message: 'Description:',
29
+ validate: (value) => validate(value, 'description'),
30
+ }),
31
+ author: await input({
32
+ message: 'Author:',
33
+ validate: (value) => validate(value, 'author'),
34
+ }),
35
+ githubOwner: await input({
36
+ message: 'GitHub owner:',
37
+ validate: (value) => validate(value, 'githubOwner'),
38
+ }),
39
+ githubRepository: await input({
40
+ message: 'GitHub repository:',
41
+ validate: (value) => validate(value, 'githubRepository'),
42
+ default: validate(defaultPackage, 'githubRepository') === true
43
+ ? defaultPackage
44
+ : undefined,
45
+ }),
46
+ };
47
+ options.typescript = await confirm({ message: 'Add typescript?' });
48
+ if (options.typescript) {
49
+ options.testing = await confirm({ message: 'Add AVA testing framework?' });
50
+ }
51
+ if (options.testing) {
52
+ options.reportCodeCoverage = await confirm({
53
+ message: 'Report code coverate to Codecov?',
54
+ });
55
+ }
56
+ options.path = await input({ message: 'Output folder:' });
57
+ options.dryRun = await confirm({ message: 'Dry run?' });
58
+ for await (const file of files(schema.parse(options))) {
59
+ console.log(`Create file ${file.path}`);
60
+ await file.write();
61
+ }
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ declare const schema: z.ZodObject<{
3
+ project: z.ZodString;
4
+ package: z.ZodEffects<z.ZodString, string, string>;
5
+ public: z.ZodDefault<z.ZodBoolean>;
6
+ description: z.ZodString;
7
+ author: z.ZodString;
8
+ typescript: z.ZodBoolean;
9
+ testing: z.ZodDefault<z.ZodBoolean>;
10
+ reportCodeCoverage: z.ZodDefault<z.ZodBoolean>;
11
+ githubOwner: z.ZodString;
12
+ githubRepository: z.ZodString;
13
+ path: z.ZodEffects<z.ZodString, string, string>;
14
+ dryRun: z.ZodDefault<z.ZodBoolean>;
15
+ }, "strict", z.ZodTypeAny, {
16
+ project: string;
17
+ package: string;
18
+ path: string;
19
+ public: boolean;
20
+ description: string;
21
+ author: string;
22
+ typescript: boolean;
23
+ testing: boolean;
24
+ reportCodeCoverage: boolean;
25
+ githubOwner: string;
26
+ githubRepository: string;
27
+ dryRun: boolean;
28
+ }, {
29
+ project: string;
30
+ package: string;
31
+ path: string;
32
+ description: string;
33
+ author: string;
34
+ typescript: boolean;
35
+ githubOwner: string;
36
+ githubRepository: string;
37
+ public?: boolean | undefined;
38
+ testing?: boolean | undefined;
39
+ reportCodeCoverage?: boolean | undefined;
40
+ dryRun?: boolean | undefined;
41
+ }>;
42
+ type Options = z.infer<typeof schema>;
43
+ export { schema, schema as options, type Options };
@@ -0,0 +1,52 @@
1
+ import fs from 'node:fs';
2
+ import { z } from 'zod';
3
+ import validatePackageName from 'validate-npm-package-name';
4
+ const schema = z
5
+ .object({
6
+ project: z.string().min(1),
7
+ package: z.string().superRefine((value, ctx) => {
8
+ const { validForNewPackages, errors, warnings } = validatePackageName(value);
9
+ if (!validForNewPackages) {
10
+ for (const message of [...(errors ?? []), ...(warnings ?? [])]) {
11
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message });
12
+ }
13
+ }
14
+ }),
15
+ public: z.boolean().default(false),
16
+ description: z.string(),
17
+ author: z.string().min(1),
18
+ typescript: z.boolean(),
19
+ testing: z.boolean().default(false),
20
+ reportCodeCoverage: z.boolean().default(false),
21
+ githubOwner: z.string().regex(/^[\w-.]+$/),
22
+ githubRepository: z.string().regex(/^[\w-.]+$/),
23
+ path: z
24
+ .string()
25
+ .min(1)
26
+ .superRefine((value, ctx) => {
27
+ const exists = fs.existsSync(value);
28
+ if (exists) {
29
+ if (!fs.statSync(value).isDirectory()) {
30
+ ctx.addIssue({
31
+ code: z.ZodIssueCode.custom,
32
+ message: 'Expected an empty directory, received a file.',
33
+ });
34
+ return z.NEVER;
35
+ }
36
+ const { files } = fs.statfsSync(value);
37
+ if (files !== 0) {
38
+ ctx.addIssue({
39
+ code: z.ZodIssueCode.custom,
40
+ message: [
41
+ 'Expected an empty directory, received a directory with',
42
+ `${files} file${files === 1 ? '' : 's'}.`,
43
+ ].join(' '),
44
+ });
45
+ }
46
+ }
47
+ }),
48
+ dryRun: z.boolean().default(false),
49
+ })
50
+ .strict();
51
+ export { schema, schema as options };
52
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1,2 @@
1
+ declare const rootPath: string;
2
+ export default rootPath;
@@ -0,0 +1,5 @@
1
+ import { resolve, dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ const rootPath = resolve(dirname(fileURLToPath(import.meta.url)), '../');
4
+ export default rootPath;
5
+ //# sourceMappingURL=root-path.js.map
package/package.json ADDED
@@ -0,0 +1,226 @@
1
+ {
2
+ "name": "@vidavidorra/create-project",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "Interactively create a GitHub project.",
6
+ "homepage": "https://github.com/vidavidorra/create-project#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/vidavidorra/create-project/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/vidavidorra/create-project.git"
13
+ },
14
+ "license": "GPL-3.0-or-later",
15
+ "author": "Jeroen de Bruijn",
16
+ "type": "module",
17
+ "exports": "./dist/index.js",
18
+ "files": [
19
+ "./dist/**/!(*.test).{js,d.ts,cjs}",
20
+ "./.github/",
21
+ "./.editorconfig",
22
+ "./.gitignore",
23
+ "./.npmrc",
24
+ "./LICENSE.md",
25
+ "./tsconfig.json"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "format": "prettier --ignore-path .gitignore --write \"**/*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}\" --log-level warn",
30
+ "format:check": "prettier --ignore-path .gitignore --check \"**/*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}\" --log-level warn",
31
+ "lint": "npm run format:check && xo",
32
+ "lint:fix": "npm run format && xo --fix",
33
+ "prepare": "husky install .github/husky",
34
+ "test": "c8 ava"
35
+ },
36
+ "commitlint": {
37
+ "extends": [
38
+ "@vidavidorra"
39
+ ]
40
+ },
41
+ "xo": {
42
+ "prettier": true,
43
+ "space": true
44
+ },
45
+ "prettier": {
46
+ "singleQuote": true
47
+ },
48
+ "release": {
49
+ "branches": [
50
+ "main",
51
+ {
52
+ "name": "beta",
53
+ "prerelease": true
54
+ }
55
+ ],
56
+ "plugins": [
57
+ [
58
+ "@semantic-release/commit-analyzer",
59
+ {
60
+ "releaseRules": [
61
+ {
62
+ "type": "perf",
63
+ "release": "patch"
64
+ },
65
+ {
66
+ "type": "revert",
67
+ "release": "patch"
68
+ },
69
+ {
70
+ "type": "docs",
71
+ "release": "patch"
72
+ },
73
+ {
74
+ "type": "chore",
75
+ "release": false
76
+ },
77
+ {
78
+ "type": "refactor",
79
+ "release": "patch"
80
+ },
81
+ {
82
+ "type": "test",
83
+ "release": "patch"
84
+ },
85
+ {
86
+ "type": "build",
87
+ "release": "patch"
88
+ },
89
+ {
90
+ "type": "ci",
91
+ "release": "patch"
92
+ }
93
+ ]
94
+ }
95
+ ],
96
+ "@semantic-release/release-notes-generator",
97
+ "@semantic-release/changelog",
98
+ [
99
+ "@semantic-release/exec",
100
+ {
101
+ "prepareCmd": "prettier --write CHANGELOG.md"
102
+ }
103
+ ],
104
+ [
105
+ "@semantic-release/npm",
106
+ {
107
+ "tarballDir": "dist"
108
+ }
109
+ ],
110
+ "@semantic-release/git",
111
+ [
112
+ "@semantic-release/github",
113
+ {
114
+ "assets": "dist/*.tgz"
115
+ }
116
+ ]
117
+ ],
118
+ "preset": "conventionalcommits",
119
+ "presetConfig": {
120
+ "types": [
121
+ {
122
+ "type": "feat",
123
+ "section": "Features"
124
+ },
125
+ {
126
+ "type": "fix",
127
+ "section": "Bug Fixes"
128
+ },
129
+ {
130
+ "type": "perf",
131
+ "section": "Performance Improvements"
132
+ },
133
+ {
134
+ "type": "revert",
135
+ "section": "Reverts"
136
+ },
137
+ {
138
+ "type": "docs",
139
+ "section": "Documentation"
140
+ },
141
+ {
142
+ "type": "style",
143
+ "section": "Styles"
144
+ },
145
+ {
146
+ "type": "chore",
147
+ "section": "Miscellaneous Chores",
148
+ "hidden": true
149
+ },
150
+ {
151
+ "type": "refactor",
152
+ "section": "Code Refactoring"
153
+ },
154
+ {
155
+ "type": "test",
156
+ "section": "Tests"
157
+ },
158
+ {
159
+ "type": "build",
160
+ "section": "Build System"
161
+ },
162
+ {
163
+ "type": "ci",
164
+ "section": "Continuous Integration"
165
+ }
166
+ ]
167
+ }
168
+ },
169
+ "ava": {
170
+ "files": [
171
+ "!worktrees",
172
+ "src/**/*.test.ts"
173
+ ],
174
+ "typescript": {
175
+ "rewritePaths": {
176
+ "src/": "dist/"
177
+ },
178
+ "compile": "tsc"
179
+ }
180
+ },
181
+ "c8": {
182
+ "include": [
183
+ "dist/**/*.js"
184
+ ],
185
+ "reporter": [
186
+ "cobertura",
187
+ "html",
188
+ "lcovonly",
189
+ "text-summary"
190
+ ]
191
+ },
192
+ "dependencies": {
193
+ "@inquirer/prompts": "2.3.0",
194
+ "prettier": "3.0.0",
195
+ "sort-package-json": "2.5.1",
196
+ "typescript": "5.1.6",
197
+ "validate-npm-package-name": "5.0.0",
198
+ "yaml": "2.3.1",
199
+ "zod": "3.21.4"
200
+ },
201
+ "devDependencies": {
202
+ "@ava/typescript": "4.0.0",
203
+ "@commitlint/cli": "17.6.5",
204
+ "@semantic-release/changelog": "6.0.3",
205
+ "@semantic-release/exec": "6.0.3",
206
+ "@semantic-release/git": "10.0.1",
207
+ "@types/node": "20.4.3",
208
+ "@types/prettier": "2.7.3",
209
+ "@types/sinon": "10.0.15",
210
+ "@types/validate-npm-package-name": "4.0.0",
211
+ "@vidavidorra/commitlint-config": "5.0.2",
212
+ "ava": "5.2.0",
213
+ "c8": "8.0.0",
214
+ "husky": "8.0.3",
215
+ "lint-staged": "13.2.2",
216
+ "semantic-release": "21.0.5",
217
+ "sinon": "15.2.0",
218
+ "xo": "0.55.0"
219
+ },
220
+ "engines": {
221
+ "node": ">=18"
222
+ },
223
+ "publishConfig": {
224
+ "access": "public"
225
+ }
226
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "module": "ES2022",
5
+ "esModuleInterop": true,
6
+ "moduleResolution": "Node16",
7
+ "outDir": "dist",
8
+ "skipLibCheck": true,
9
+ "sourceMap": true,
10
+ "strict": true,
11
+ "target": "ES2022"
12
+ },
13
+ "include": ["src/**/*.ts"]
14
+ }