@vidavidorra/create-project 1.0.0 → 1.0.2
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 +8 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +64 -0
- package/dist/content/package.d.ts +15 -11
- package/dist/content/package.js +7 -1
- package/dist/create-project.d.ts +3 -0
- package/dist/create-project.js +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -61
- package/dist/options.d.ts +2 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Interactively create a project.
|
|
|
9
9
|
|
|
10
10
|
[](https://www.npmjs.com/package/@vidavidorra/create-project)
|
|
11
11
|
[](https://www.npmjs.com/package/@vidavidorra/create-project)
|
|
12
|
-
[](https://nodejs.org/en/about/releases/)
|
|
13
13
|
[](https://renovatebot.com)
|
|
14
14
|
[](https://github.com/semantic-release/semantic-release)
|
|
15
15
|
[](https://codecov.io/gh/vidavidorra/create-project)
|
|
@@ -32,7 +32,13 @@ npm install --global @vidavidorra/create-project
|
|
|
32
32
|
Start the interactive CLI to create a project.
|
|
33
33
|
|
|
34
34
|
```shell
|
|
35
|
-
|
|
35
|
+
create-project
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or run the interactive CLI directly via `npx`.
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
npx @vidavidorra/create-project
|
|
36
42
|
```
|
|
37
43
|
|
|
38
44
|
## Contributing
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { input, confirm } from '@inquirer/prompts';
|
|
3
|
+
import { createProject, options as schema } from './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
|
+
const files = await createProject(schema.parse(options));
|
|
59
|
+
if (options.dryRun) {
|
|
60
|
+
for (const path of files) {
|
|
61
|
+
console.log(`Create file ${path}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -28,6 +28,7 @@ declare const schema: z.ZodObject<{
|
|
|
28
28
|
author: z.ZodString;
|
|
29
29
|
type: z.ZodLiteral<"module">;
|
|
30
30
|
exports: z.ZodOptional<z.ZodString>;
|
|
31
|
+
bin: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
32
|
files: z.ZodOptional<z.ZodTuple<[z.ZodLiteral<"./dist/**/!(*.test).{js,d.ts,cjs}">], z.ZodString>>;
|
|
32
33
|
scripts: z.ZodObject<{
|
|
33
34
|
build: z.ZodString;
|
|
@@ -69,13 +70,13 @@ declare const schema: z.ZodObject<{
|
|
|
69
70
|
}, {
|
|
70
71
|
node: ">=18";
|
|
71
72
|
}>;
|
|
72
|
-
publishConfig: z.ZodObject<{
|
|
73
|
+
publishConfig: z.ZodOptional<z.ZodObject<{
|
|
73
74
|
access: z.ZodLiteral<"public">;
|
|
74
75
|
}, "strict", z.ZodTypeAny, {
|
|
75
76
|
access: "public";
|
|
76
77
|
}, {
|
|
77
78
|
access: "public";
|
|
78
|
-
}
|
|
79
|
+
}>>;
|
|
79
80
|
}, "strict", z.ZodTypeAny, {
|
|
80
81
|
type: "module";
|
|
81
82
|
description: string;
|
|
@@ -108,15 +109,16 @@ declare const schema: z.ZodObject<{
|
|
|
108
109
|
engines: {
|
|
109
110
|
node: ">=18";
|
|
110
111
|
};
|
|
111
|
-
publishConfig: {
|
|
112
|
-
access: "public";
|
|
113
|
-
};
|
|
114
112
|
private?: boolean | undefined;
|
|
115
113
|
exports?: string | undefined;
|
|
114
|
+
bin?: Record<string, unknown> | undefined;
|
|
116
115
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
117
116
|
ava?: Record<string, unknown> | undefined;
|
|
118
117
|
c8?: Record<string, unknown> | undefined;
|
|
119
118
|
dependencies?: Record<string, string> | undefined;
|
|
119
|
+
publishConfig?: {
|
|
120
|
+
access: "public";
|
|
121
|
+
} | undefined;
|
|
120
122
|
}, {
|
|
121
123
|
type: "module";
|
|
122
124
|
description: string;
|
|
@@ -149,15 +151,16 @@ declare const schema: z.ZodObject<{
|
|
|
149
151
|
engines: {
|
|
150
152
|
node: ">=18";
|
|
151
153
|
};
|
|
152
|
-
publishConfig: {
|
|
153
|
-
access: "public";
|
|
154
|
-
};
|
|
155
154
|
private?: boolean | undefined;
|
|
156
155
|
exports?: string | undefined;
|
|
156
|
+
bin?: Record<string, unknown> | undefined;
|
|
157
157
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
158
158
|
ava?: Record<string, unknown> | undefined;
|
|
159
159
|
c8?: Record<string, unknown> | undefined;
|
|
160
160
|
dependencies?: Record<string, string> | undefined;
|
|
161
|
+
publishConfig?: {
|
|
162
|
+
access: "public";
|
|
163
|
+
} | undefined;
|
|
161
164
|
}>;
|
|
162
165
|
type PackageJson = z.infer<typeof schema>;
|
|
163
166
|
declare class Package extends File {
|
|
@@ -196,15 +199,16 @@ declare class Package extends File {
|
|
|
196
199
|
engines: {
|
|
197
200
|
node: ">=18";
|
|
198
201
|
};
|
|
199
|
-
publishConfig: {
|
|
200
|
-
access: "public";
|
|
201
|
-
};
|
|
202
202
|
private?: boolean | undefined;
|
|
203
203
|
exports?: string | undefined;
|
|
204
|
+
bin?: Record<string, unknown> | undefined;
|
|
204
205
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
205
206
|
ava?: Record<string, unknown> | undefined;
|
|
206
207
|
c8?: Record<string, unknown> | undefined;
|
|
207
208
|
dependencies?: Record<string, string> | undefined;
|
|
209
|
+
publishConfig?: {
|
|
210
|
+
access: "public";
|
|
211
|
+
} | undefined;
|
|
208
212
|
};
|
|
209
213
|
process(): this;
|
|
210
214
|
}
|
package/dist/content/package.js
CHANGED
|
@@ -23,6 +23,7 @@ const schema = z
|
|
|
23
23
|
author: z.string().min(1),
|
|
24
24
|
type: z.literal('module'),
|
|
25
25
|
exports: z.string().min(1).optional(),
|
|
26
|
+
bin: z.record(z.unknown()).optional(),
|
|
26
27
|
files: z
|
|
27
28
|
.tuple([z.literal('./dist/**/!(*.test).{js,d.ts,cjs}')])
|
|
28
29
|
.rest(z.string().min(1))
|
|
@@ -49,7 +50,10 @@ const schema = z
|
|
|
49
50
|
dependencies: z.record(z.string()).optional(),
|
|
50
51
|
devDependencies: z.record(z.string()),
|
|
51
52
|
engines: z.object({ node: z.literal('>=18') }).strict(),
|
|
52
|
-
publishConfig: z
|
|
53
|
+
publishConfig: z
|
|
54
|
+
.object({ access: z.literal('public') })
|
|
55
|
+
.strict()
|
|
56
|
+
.optional(),
|
|
53
57
|
})
|
|
54
58
|
.strict();
|
|
55
59
|
class Package extends File {
|
|
@@ -72,12 +76,14 @@ class Package extends File {
|
|
|
72
76
|
...this._package.devDependencies,
|
|
73
77
|
...this._package.dependencies,
|
|
74
78
|
};
|
|
79
|
+
delete this._package.bin;
|
|
75
80
|
delete this._package.dependencies;
|
|
76
81
|
if (this._options.public) {
|
|
77
82
|
delete this._package.private;
|
|
78
83
|
}
|
|
79
84
|
else {
|
|
80
85
|
this._package.private = true;
|
|
86
|
+
delete this._package.publishConfig;
|
|
81
87
|
}
|
|
82
88
|
const devDependencies = [
|
|
83
89
|
'@commitlint/cli',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { schema } from './options.js';
|
|
2
|
+
import { files } from './content/index.js';
|
|
3
|
+
async function createProject(options) {
|
|
4
|
+
const paths = [];
|
|
5
|
+
for await (const file of files(schema.parse(options))) {
|
|
6
|
+
await file.write();
|
|
7
|
+
paths.push(file.path);
|
|
8
|
+
}
|
|
9
|
+
return paths;
|
|
10
|
+
}
|
|
11
|
+
export { createProject };
|
|
12
|
+
//# sourceMappingURL=create-project.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { type OptionsInput as Options, options } from './options.js';
|
|
2
|
+
export { createProject } from './create-project.js';
|
package/dist/index.js
CHANGED
|
@@ -1,62 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
}
|
|
1
|
+
export { options } from './options.js';
|
|
2
|
+
export { createProject } from './create-project.js';
|
|
62
3
|
//# sourceMappingURL=index.js.map
|
package/dist/options.d.ts
CHANGED
|
@@ -39,5 +39,6 @@ declare const schema: z.ZodObject<{
|
|
|
39
39
|
reportCodeCoverage?: boolean | undefined;
|
|
40
40
|
dryRun?: boolean | undefined;
|
|
41
41
|
}>;
|
|
42
|
+
type OptionsInput = z.input<typeof schema>;
|
|
42
43
|
type Options = z.infer<typeof schema>;
|
|
43
|
-
export { schema, schema as options, type Options };
|
|
44
|
+
export { schema, schema as options, type Options, type OptionsInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vidavidorra/create-project",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interactively create a GitHub project.",
|
|
6
6
|
"homepage": "https://github.com/vidavidorra/create-project#readme",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"author": "Jeroen de Bruijn",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": "./dist/index.js",
|
|
18
|
+
"bin": {
|
|
19
|
+
"create-project": "./dist/cli.js"
|
|
20
|
+
},
|
|
18
21
|
"files": [
|
|
19
22
|
"./dist/**/!(*.test).{js,d.ts,cjs}",
|
|
20
23
|
"./.github/",
|
|
@@ -179,6 +182,7 @@
|
|
|
179
182
|
}
|
|
180
183
|
},
|
|
181
184
|
"c8": {
|
|
185
|
+
"all": true,
|
|
182
186
|
"include": [
|
|
183
187
|
"dist/**/*.js"
|
|
184
188
|
],
|