@vidavidorra/create-project 1.0.1 → 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 +4 -0
- package/dist/content/package.js +2 -0
- 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;
|
|
@@ -110,6 +111,7 @@ declare const schema: z.ZodObject<{
|
|
|
110
111
|
};
|
|
111
112
|
private?: boolean | undefined;
|
|
112
113
|
exports?: string | undefined;
|
|
114
|
+
bin?: Record<string, unknown> | undefined;
|
|
113
115
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
114
116
|
ava?: Record<string, unknown> | undefined;
|
|
115
117
|
c8?: Record<string, unknown> | undefined;
|
|
@@ -151,6 +153,7 @@ declare const schema: z.ZodObject<{
|
|
|
151
153
|
};
|
|
152
154
|
private?: boolean | undefined;
|
|
153
155
|
exports?: string | undefined;
|
|
156
|
+
bin?: Record<string, unknown> | undefined;
|
|
154
157
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
155
158
|
ava?: Record<string, unknown> | undefined;
|
|
156
159
|
c8?: Record<string, unknown> | undefined;
|
|
@@ -198,6 +201,7 @@ declare class Package extends File {
|
|
|
198
201
|
};
|
|
199
202
|
private?: boolean | undefined;
|
|
200
203
|
exports?: string | undefined;
|
|
204
|
+
bin?: Record<string, unknown> | undefined;
|
|
201
205
|
files?: ["./dist/**/!(*.test).{js,d.ts,cjs}", ...string[]] | undefined;
|
|
202
206
|
ava?: Record<string, unknown> | undefined;
|
|
203
207
|
c8?: Record<string, unknown> | undefined;
|
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))
|
|
@@ -75,6 +76,7 @@ class Package extends File {
|
|
|
75
76
|
...this._package.devDependencies,
|
|
76
77
|
...this._package.dependencies,
|
|
77
78
|
};
|
|
79
|
+
delete this._package.bin;
|
|
78
80
|
delete this._package.dependencies;
|
|
79
81
|
if (this._options.public) {
|
|
80
82
|
delete this._package.private;
|
|
@@ -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
|
],
|