@vidavidorra/create-project 1.0.2 → 1.0.4

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
@@ -53,7 +53,10 @@ if (options.testing) {
53
53
  message: 'Report code coverate to Codecov?',
54
54
  });
55
55
  }
56
- options.path = await input({ message: 'Output folder:' });
56
+ options.path = await input({
57
+ message: 'Output folder:',
58
+ validate: (value) => validate(value, 'path'),
59
+ });
57
60
  options.dryRun = await confirm({ message: 'Dry run?' });
58
61
  const files = await createProject(schema.parse(options));
59
62
  if (options.dryRun) {
@@ -36,6 +36,7 @@ declare const schema: z.ZodObject<{
36
36
  'format:check': z.ZodString;
37
37
  lint: z.ZodLiteral<"npm run format:check && xo">;
38
38
  'lint:fix': z.ZodLiteral<"npm run format && xo --fix">;
39
+ postinstall: z.ZodOptional<z.ZodString>;
39
40
  prepare: z.ZodLiteral<"husky install .github/husky">;
40
41
  test: z.ZodString;
41
42
  }, "strict", z.ZodTypeAny, {
@@ -46,6 +47,7 @@ declare const schema: z.ZodObject<{
46
47
  'format:check': string;
47
48
  'lint:fix': "npm run format && xo --fix";
48
49
  prepare: "husky install .github/husky";
50
+ postinstall?: string | undefined;
49
51
  }, {
50
52
  format: string;
51
53
  lint: "npm run format:check && xo";
@@ -54,6 +56,7 @@ declare const schema: z.ZodObject<{
54
56
  'format:check': string;
55
57
  'lint:fix': "npm run format && xo --fix";
56
58
  prepare: "husky install .github/husky";
59
+ postinstall?: string | undefined;
57
60
  }>;
58
61
  commitlint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
59
62
  xo: z.ZodRecord<z.ZodString, z.ZodUnknown>;
@@ -102,6 +105,7 @@ declare const schema: z.ZodObject<{
102
105
  'format:check': string;
103
106
  'lint:fix': "npm run format && xo --fix";
104
107
  prepare: "husky install .github/husky";
108
+ postinstall?: string | undefined;
105
109
  };
106
110
  commitlint: Record<string, unknown>;
107
111
  xo: Record<string, unknown>;
@@ -144,6 +148,7 @@ declare const schema: z.ZodObject<{
144
148
  'format:check': string;
145
149
  'lint:fix': "npm run format && xo --fix";
146
150
  prepare: "husky install .github/husky";
151
+ postinstall?: string | undefined;
147
152
  };
148
153
  commitlint: Record<string, unknown>;
149
154
  xo: Record<string, unknown>;
@@ -192,6 +197,7 @@ declare class Package extends File {
192
197
  'format:check': string;
193
198
  'lint:fix': "npm run format && xo --fix";
194
199
  prepare: "husky install .github/husky";
200
+ postinstall?: string | undefined;
195
201
  };
196
202
  commitlint: Record<string, unknown>;
197
203
  xo: Record<string, unknown>;
@@ -37,6 +37,7 @@ const schema = z
37
37
  lint: z.literal('npm run format:check && xo'),
38
38
  // eslint-disable-next-line @typescript-eslint/naming-convention
39
39
  'lint:fix': z.literal('npm run format && xo --fix'),
40
+ postinstall: z.string().optional(),
40
41
  prepare: z.literal('husky install .github/husky'),
41
42
  test: z.string().min(1),
42
43
  })
@@ -78,6 +79,7 @@ class Package extends File {
78
79
  };
79
80
  delete this._package.bin;
80
81
  delete this._package.dependencies;
82
+ delete this._package.scripts.postinstall;
81
83
  if (this._options.public) {
82
84
  delete this._package.private;
83
85
  }
@@ -0,0 +1,13 @@
1
+ declare const gitIgnore: string;
2
+ declare const npmIgnore: string;
3
+ /**
4
+ * Workaround for [Rename `.gitignore` to `.npmignore` in package if no
5
+ * `.npmignore` found](https://github.com/npm/npm/issues/1862) and ['npm pack'/
6
+ * `publish` option to not rename or keep a copy of `.gitignore` files](
7
+ * https://github.com/npm/npm/issues/7252) issues. With npm v9 or newer, the
8
+ * `npm pack` includes the `.gitignore` in the tarball and `npm install` renames
9
+ * the file to `.npmignore`. This script simply reverts that rename if it has
10
+ * occurred.
11
+ */
12
+ declare function postinstall(): void;
13
+ export { gitIgnore, npmIgnore, postinstall };
@@ -0,0 +1,27 @@
1
+ import { join } from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { argv } from 'node:process';
5
+ import rootPath from '../root-path.js';
6
+ const gitIgnore = join(rootPath, '.gitignore');
7
+ const npmIgnore = join(rootPath, '.npmignore');
8
+ /**
9
+ * Workaround for [Rename `.gitignore` to `.npmignore` in package if no
10
+ * `.npmignore` found](https://github.com/npm/npm/issues/1862) and ['npm pack'/
11
+ * `publish` option to not rename or keep a copy of `.gitignore` files](
12
+ * https://github.com/npm/npm/issues/7252) issues. With npm v9 or newer, the
13
+ * `npm pack` includes the `.gitignore` in the tarball and `npm install` renames
14
+ * the file to `.npmignore`. This script simply reverts that rename if it has
15
+ * occurred.
16
+ */
17
+ function postinstall() {
18
+ if (fs.existsSync(npmIgnore) && !fs.existsSync(gitIgnore)) {
19
+ fs.renameSync(npmIgnore, gitIgnore);
20
+ }
21
+ }
22
+ if (import.meta.url.startsWith('file:') &&
23
+ fileURLToPath(import.meta.url) === argv.at(1)) {
24
+ postinstall();
25
+ }
26
+ export { gitIgnore, npmIgnore, postinstall };
27
+ //# sourceMappingURL=postinstall.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidavidorra/create-project",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "Interactively create a GitHub project.",
6
6
  "homepage": "https://github.com/vidavidorra/create-project#readme",
@@ -31,6 +31,7 @@
31
31
  "build": "tsc",
32
32
  "format": "prettier --ignore-path .gitignore --write \"**/*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}\" --log-level warn",
33
33
  "format:check": "prettier --ignore-path .gitignore --check \"**/*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}\" --log-level warn",
34
+ "postinstall": "node ./dist/scripts/postinstall.js",
34
35
  "lint": "npm run format:check && xo",
35
36
  "lint:fix": "npm run format && xo --fix",
36
37
  "prepare": "husky install .github/husky",