complete-cli 1.0.30 → 1.0.32
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/commands/init/createProject.js +13 -3
- package/dist/git.js +6 -6
- package/dist/prompt.js +5 -3
- package/package.json +6 -6
- package/src/commands/init/createProject.ts +16 -3
- package/src/git.ts +6 -6
- package/src/prompt.ts +5 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { assertObject, repeat } from "complete-common";
|
|
3
|
-
import { $q, copyFileOrDirectory, formatWithPrettier, getFileNamesInDirectory, getPackageJSON, getPackageManagerInstallCICommand, getPackageManagerInstallCommand, isFile, makeDirectory, readFile, renameFile, updatePackageJSONDependencies, writeFile, writeFileAsync, } from "complete-node";
|
|
3
|
+
import { $q, copyFileOrDirectory, formatWithPrettier, getFileNamesInDirectory, getPackageJSON, getPackageManagerInstallCICommand, getPackageManagerInstallCommand, isFile, makeDirectory, PackageManager, readFile, renameFile, updatePackageJSONDependencies, writeFile, writeFileAsync, } from "complete-node";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { ACTION_YML, ACTION_YML_TEMPLATE_PATH, TEMPLATES_DYNAMIC_DIR, TEMPLATES_STATIC_DIR, } from "../../constants.js";
|
|
6
6
|
import { initGitRepository } from "../../git.js";
|
|
@@ -12,6 +12,7 @@ export async function createProject(projectName, authorName, projectPath, create
|
|
|
12
12
|
}
|
|
13
13
|
copyStaticFiles(projectPath);
|
|
14
14
|
copyDynamicFiles(projectName, authorName, projectPath, packageManager);
|
|
15
|
+
copyPackageManagerSpecificFiles(projectPath, packageManager);
|
|
15
16
|
// There is no package manager lock files yet, so we have to pass "false" to this function.
|
|
16
17
|
const updated = await updatePackageJSONDependencies(projectPath, false, true);
|
|
17
18
|
if (!updated) {
|
|
@@ -110,8 +111,17 @@ function copyDynamicFiles(projectName, authorName, projectPath, packageManager)
|
|
|
110
111
|
const destinationPath = path.join(projectPath, "README.md");
|
|
111
112
|
writeFile(destinationPath, readmeMD);
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
}
|
|
115
|
+
function copyPackageManagerSpecificFiles(projectPath, packageManager) {
|
|
116
|
+
if (packageManager === PackageManager.pnpm) {
|
|
117
|
+
// `pnpm` requires the `shamefully-hoist` option to be enabled for "complete-lint" to work
|
|
118
|
+
// correctly.
|
|
119
|
+
const npmrc = `save-exact=true
|
|
120
|
+
shamefully-hoist=true
|
|
121
|
+
`;
|
|
122
|
+
const npmrcPath = path.join(projectPath, ".npmrc");
|
|
123
|
+
writeFile(npmrcPath, npmrc);
|
|
124
|
+
}
|
|
115
125
|
}
|
|
116
126
|
async function revertVersionsInPackageJSON(projectPath) {
|
|
117
127
|
const packageJSONPath = path.join(projectPath, "package.json");
|
package/dist/git.js
CHANGED
|
@@ -119,15 +119,15 @@ export async function initGitRepository(projectPath, gitRemoteURL) {
|
|
|
119
119
|
if (gitRemoteURL === undefined) {
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
const $$ = $q({ cwd: projectPath });
|
|
123
|
-
await $$ `git init --initial-branch main`;
|
|
124
|
-
await $$ `git remote add origin ${gitRemoteURL}`;
|
|
122
|
+
const $$q = $q({ cwd: projectPath });
|
|
123
|
+
await $$q `git init --initial-branch main`;
|
|
124
|
+
await $$q `git remote add origin ${gitRemoteURL}`;
|
|
125
125
|
const gitNameAndEmailConfigured = await isGitNameAndEmailConfigured();
|
|
126
126
|
if (gitNameAndEmailConfigured) {
|
|
127
|
-
await $$ `git add --all`;
|
|
127
|
+
await $$q `git add --all`;
|
|
128
128
|
const commitMessage = `chore: add files from ${PROJECT_NAME} ${PROJECT_VERSION} template`;
|
|
129
|
-
await $$ `git commit --message ${commitMessage}`;
|
|
130
|
-
await $$ `git push --set-upstream origin main`;
|
|
129
|
+
await $$q `git commit --message ${commitMessage}`;
|
|
130
|
+
await $$q `git push --set-upstream origin main`;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
async function isGitNameAndEmailConfigured() {
|
package/dist/prompt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Both the Inquirer.js library and the Prompts library have a bug where text is duplicated in a Git
|
|
2
2
|
// Bash terminal. Thus, we revert to using the simpler Prompt library.
|
|
3
|
-
import { cancel, confirm, intro, isCancel, log, outro, spinner, text, } from "@clack
|
|
3
|
+
import { cancel, confirm, intro, isCancel, log, outro, spinner, text, } from "@zamiell/clack-prompts";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { PROJECT_NAME } from "./constants.js";
|
|
6
6
|
export function promptStart() {
|
|
@@ -31,8 +31,10 @@ export async function getInputString(msg, defaultValue) {
|
|
|
31
31
|
cancel("Canceled.");
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// The "text" return type is bugged: "input" is equal to "undefined" if the user did not enter any
|
|
35
|
+
// input.
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
37
|
+
if (input === undefined || input.trim() === "") {
|
|
36
38
|
promptError("You must enter a non-empty value.");
|
|
37
39
|
}
|
|
38
40
|
return input.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "complete-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "A command line tool for bootstrapping TypeScript projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -34,22 +34,22 @@
|
|
|
34
34
|
"test": "glob \"./src/**/*.test.ts\" --cmd=\"node --import tsx --test --test-reporter spec\""
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@clack
|
|
37
|
+
"@zamiell/clack-prompts": "0.10.2",
|
|
38
38
|
"chalk": "5.4.1",
|
|
39
39
|
"clipanion": "4.0.0-rc.4",
|
|
40
|
-
"complete-common": "1.
|
|
41
|
-
"complete-node": "5.1.
|
|
40
|
+
"complete-common": "2.1.0",
|
|
41
|
+
"complete-node": "5.1.2",
|
|
42
42
|
"klaw-sync": "6.0.0",
|
|
43
43
|
"yaml": "2.7.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/klaw-sync": "6.0.5",
|
|
47
|
-
"@types/node": "22.13.
|
|
47
|
+
"@types/node": "22.13.10",
|
|
48
48
|
"glob": "11.0.1",
|
|
49
49
|
"ts-loader": "9.5.2",
|
|
50
50
|
"tsconfig-paths-webpack-plugin": "4.2.0",
|
|
51
51
|
"typescript": "5.8.2",
|
|
52
|
-
"typescript-eslint": "8.26.
|
|
52
|
+
"typescript-eslint": "8.26.1",
|
|
53
53
|
"webpack": "5.98.0",
|
|
54
54
|
"webpack-cli": "6.0.1",
|
|
55
55
|
"webpack-shebang-plugin": "1.1.8"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { assertObject, repeat } from "complete-common";
|
|
3
|
-
import type { PackageManager } from "complete-node";
|
|
4
3
|
import {
|
|
5
4
|
$q,
|
|
6
5
|
copyFileOrDirectory,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
getPackageManagerInstallCommand,
|
|
12
11
|
isFile,
|
|
13
12
|
makeDirectory,
|
|
13
|
+
PackageManager,
|
|
14
14
|
readFile,
|
|
15
15
|
renameFile,
|
|
16
16
|
updatePackageJSONDependencies,
|
|
@@ -43,6 +43,7 @@ export async function createProject(
|
|
|
43
43
|
|
|
44
44
|
copyStaticFiles(projectPath);
|
|
45
45
|
copyDynamicFiles(projectName, authorName, projectPath, packageManager);
|
|
46
|
+
copyPackageManagerSpecificFiles(projectPath, packageManager);
|
|
46
47
|
|
|
47
48
|
// There is no package manager lock files yet, so we have to pass "false" to this function.
|
|
48
49
|
const updated = await updatePackageJSONDependencies(projectPath, false, true);
|
|
@@ -178,9 +179,21 @@ function copyDynamicFiles(
|
|
|
178
179
|
const destinationPath = path.join(projectPath, "README.md");
|
|
179
180
|
writeFile(destinationPath, readmeMD);
|
|
180
181
|
}
|
|
182
|
+
}
|
|
181
183
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
function copyPackageManagerSpecificFiles(
|
|
185
|
+
projectPath: string,
|
|
186
|
+
packageManager: PackageManager,
|
|
187
|
+
) {
|
|
188
|
+
if (packageManager === PackageManager.pnpm) {
|
|
189
|
+
// `pnpm` requires the `shamefully-hoist` option to be enabled for "complete-lint" to work
|
|
190
|
+
// correctly.
|
|
191
|
+
const npmrc = `save-exact=true
|
|
192
|
+
shamefully-hoist=true
|
|
193
|
+
`;
|
|
194
|
+
const npmrcPath = path.join(projectPath, ".npmrc");
|
|
195
|
+
writeFile(npmrcPath, npmrc);
|
|
196
|
+
}
|
|
184
197
|
}
|
|
185
198
|
|
|
186
199
|
async function revertVersionsInPackageJSON(projectPath: string) {
|
package/src/git.ts
CHANGED
|
@@ -163,17 +163,17 @@ export async function initGitRepository(
|
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const $$ = $q({ cwd: projectPath });
|
|
166
|
+
const $$q = $q({ cwd: projectPath });
|
|
167
167
|
|
|
168
|
-
await
|
|
169
|
-
await
|
|
168
|
+
await $$q`git init --initial-branch main`;
|
|
169
|
+
await $$q`git remote add origin ${gitRemoteURL}`;
|
|
170
170
|
|
|
171
171
|
const gitNameAndEmailConfigured = await isGitNameAndEmailConfigured();
|
|
172
172
|
if (gitNameAndEmailConfigured) {
|
|
173
|
-
await
|
|
173
|
+
await $$q`git add --all`;
|
|
174
174
|
const commitMessage = `chore: add files from ${PROJECT_NAME} ${PROJECT_VERSION} template`;
|
|
175
|
-
await
|
|
176
|
-
await
|
|
175
|
+
await $$q`git commit --message ${commitMessage}`;
|
|
176
|
+
await $$q`git push --set-upstream origin main`;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
package/src/prompt.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
outro,
|
|
11
11
|
spinner,
|
|
12
12
|
text,
|
|
13
|
-
} from "@clack
|
|
13
|
+
} from "@zamiell/clack-prompts";
|
|
14
14
|
import chalk from "chalk";
|
|
15
15
|
import { PROJECT_NAME } from "./constants.js";
|
|
16
16
|
|
|
@@ -55,8 +55,10 @@ export async function getInputString(
|
|
|
55
55
|
process.exit(1);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
// The "text" return type is bugged: "input" is equal to "undefined" if the user did not enter any
|
|
59
|
+
// input.
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
61
|
+
if (input === undefined || input.trim() === "") {
|
|
60
62
|
promptError("You must enter a non-empty value.");
|
|
61
63
|
}
|
|
62
64
|
|