isaacscript 1.2.27 → 1.2.28
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/package.json +5 -5
- package/dist/src/commands/copy/copy.js +0 -1
- package/dist/src/commands/copy/copy.js.map +1 -1
- package/dist/src/commands/init/createMod.js +18 -106
- package/dist/src/commands/init/createMod.js.map +1 -1
- package/dist/src/commands/init/getProjectPath.js +4 -2
- package/dist/src/commands/init/getProjectPath.js.map +1 -1
- package/dist/src/commands/init/git.js +167 -0
- package/dist/src/commands/init/git.js.map +1 -0
- package/dist/src/commands/init/init.js +3 -1
- package/dist/src/commands/init/init.js.map +1 -1
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js +0 -5
- package/dist/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.js.map +1 -1
- package/dist/src/commands/publish/publish.js +3 -20
- package/dist/src/commands/publish/publish.js.map +1 -1
- package/dist/src/configFile.js +2 -2
- package/dist/src/configFile.js.map +1 -1
- package/dist/src/prompt.js +1 -0
- package/dist/src/prompt.js.map +1 -1
- package/{src → file-templates/static}/plugins/addCrashDebugStatements.ts +0 -0
- package/file-templates/static/plugins/addIsaacScriptCommentHeader.ts +35 -0
- package/file-templates/static/tsconfig.json +8 -0
- package/isaacscript-watcher/metadata.xml +5 -5
- package/package.json +5 -5
- package/src/commands/copy/copy.ts +0 -1
- package/src/commands/init/createMod.ts +29 -188
- package/src/commands/init/getProjectPath.ts +5 -3
- package/src/commands/init/git.ts +232 -0
- package/src/commands/init/init.ts +8 -1
- package/src/commands/monitor/modDirectorySyncer/modDirectorySyncer.ts +0 -6
- package/src/commands/publish/publish.ts +1 -25
- package/src/configFile.ts +3 -3
- package/src/exec.ts +1 -1
- package/src/prompt.ts +1 -0
- package/dist/src/monkeyPatch.js +0 -82
- package/dist/src/monkeyPatch.js.map +0 -1
- package/dist/src/plugins/addCrashDebugStatements.js +0 -44
- package/dist/src/plugins/addCrashDebugStatements.js.map +0 -1
- package/src/monkeyPatch.ts +0 -62
package/dist/src/configFile.js
CHANGED
|
@@ -38,7 +38,7 @@ const utils_1 = require("./utils");
|
|
|
38
38
|
async function get(argv) {
|
|
39
39
|
const verbose = argv.verbose === true;
|
|
40
40
|
const existingConfig = readExistingConfig();
|
|
41
|
-
if (existingConfig !==
|
|
41
|
+
if (existingConfig !== undefined) {
|
|
42
42
|
return existingConfig;
|
|
43
43
|
}
|
|
44
44
|
// No config file exists, so prompt the user for some information and create one
|
|
@@ -51,7 +51,7 @@ async function get(argv) {
|
|
|
51
51
|
exports.get = get;
|
|
52
52
|
function readExistingConfig() {
|
|
53
53
|
if (!file.exists(constants_1.CONFIG_FILE_PATH)) {
|
|
54
|
-
return
|
|
54
|
+
return undefined;
|
|
55
55
|
}
|
|
56
56
|
const configRaw = file.read(constants_1.CONFIG_FILE_PATH);
|
|
57
57
|
let config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../src/configFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,oDAAsC;AACtC,gDAAwB;AACxB,2DAAwD;AACxD,mEAAgE;AAChE,2CAAsE;AACtE,6CAA+B;AAE/B,mCAAgC;AAEzB,KAAK,UAAU,GAAG,CAAC,IAA6B;IACrD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC;IAEtC,MAAM,cAAc,GAAG,kBAAkB,EAAE,CAAC;IAC5C,IAAI,cAAc,KAAK,
|
|
1
|
+
{"version":3,"file":"configFile.js","sourceRoot":"","sources":["../../src/configFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,oDAAsC;AACtC,gDAAwB;AACxB,2DAAwD;AACxD,mEAAgE;AAChE,2CAAsE;AACtE,6CAA+B;AAE/B,mCAAgC;AAEzB,KAAK,UAAU,GAAG,CAAC,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,4BAAgB,wBAAwB,KAAK,YAAY,WAAW,iBAAiB,CAC9F,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAAC,aAAqB,EAAE,QAAgB;IAClE,OAAO;QACL,aAAa;QACb,QAAQ;KACT,CAAC;AACJ,CAAC;AALD,oCAKC;AAED,SAAgB,UAAU,CACxB,WAAmB,EACnB,MAAc,EACd,OAAgB;IAEhB,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,4BAAgB,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AARD,gCAQC"}
|
package/dist/src/prompt.js
CHANGED
|
@@ -54,6 +54,7 @@ async function getInputYesNo(msg, defaultValue = true) {
|
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
exports.getInputYesNo = getInputYesNo;
|
|
57
|
+
/** Returns trimmed input. */
|
|
57
58
|
async function getInputString(msg, defaultValue) {
|
|
58
59
|
prompt_1.default.start();
|
|
59
60
|
let description = `${chalk_1.default.bold(msg)}`;
|
package/dist/src/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompt.ts"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,gBAAgB;AAChB,sDAAsD;;;;;;AAEtD,kDAA0B;AAC1B,oDAA4B;AAC5B,mCAA8C;AAE9C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAEhD,SAAgB,UAAU;IACxB,uDAAuD;IACvD,6DAA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,QAAQ,EAAE;QAChC,IAAA,aAAK,EAAC,0DAA0D,CAAC,CAAC;KACnE;IAED,IAAI,QAAQ,KAAK,EAAE,IAAI,YAAY,KAAK,SAAS,EAAE;QACjD,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AA7BD,wCA6BC;AAEM,KAAK,UAAU,WAAW,CAC/B,GAAW,EACX,YAAY,GAAG,CAAC;IAEhB,MAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,IAAA,oBAAY,EAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACrB,IAAA,aAAK,EAAC,mCAAmC,CAAC,CAAC;KAC5C;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,kCAaC"}
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
import * as tstl from "typescript-to-lua";
|
|
3
|
+
|
|
4
|
+
const INFORMATIONAL_HEADER = `--[[
|
|
5
|
+
|
|
6
|
+
This Isaac mod was created with the IsaacScript tool.
|
|
7
|
+
|
|
8
|
+
The Lua code in this file is not actually the source code for the program. Rather, it was
|
|
9
|
+
automatically generated from higher-level TypeScript code, and might be hard to read. If you want to
|
|
10
|
+
understand how the code in this mod works, you should read the actual TypeScript source code
|
|
11
|
+
directly instead of trying to read this file. Usually, the link to the source code can be found in
|
|
12
|
+
the mod's description on the Steam Workshop. If not, you can ask the mod author directly if the
|
|
13
|
+
source code is publicly available.
|
|
14
|
+
|
|
15
|
+
IsaacScript provides a lot of advantages over using raw Lua. For more information about the tool,
|
|
16
|
+
see the official website: https://isaacscript.github.io/
|
|
17
|
+
|
|
18
|
+
--]]
|
|
19
|
+
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const plugin: tstl.Plugin = {
|
|
23
|
+
beforeEmit(
|
|
24
|
+
_program: ts.Program,
|
|
25
|
+
_options: tstl.CompilerOptions,
|
|
26
|
+
_emitHost: tstl.EmitHost,
|
|
27
|
+
result: tstl.EmitFile[],
|
|
28
|
+
) {
|
|
29
|
+
for (const file of result) {
|
|
30
|
+
file.code = `${INFORMATIONAL_HEADER}${file.code}`;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default plugin;
|
|
@@ -20,5 +20,13 @@
|
|
|
20
20
|
"luaTarget": "5.3",
|
|
21
21
|
"luaBundle": "./mod/main.lua", // Will bundle all output Lua files into a single file
|
|
22
22
|
"luaBundleEntry": "./src/bundleEntry.ts", // This invokes the "main.ts" file
|
|
23
|
+
"luaPlugins": [
|
|
24
|
+
// A plugin to emit a helper comment at the top of the compiled "main.lua" file
|
|
25
|
+
{ "name": "./plugins/addIsaacScriptCommentHeader.ts" },
|
|
26
|
+
|
|
27
|
+
// Uncomment this and recompile the mod to enable crash debugging, which will tell you the
|
|
28
|
+
// exact line of the mod that is causing the crash
|
|
29
|
+
// { "name": "./plugins/addCrashDebugStatements.ts" },
|
|
30
|
+
],
|
|
23
31
|
},
|
|
24
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<metadata>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<name>IsaacScript Watcher</name>
|
|
3
|
+
<directory>isaacscript-watcher</directory>
|
|
4
|
+
<description />
|
|
5
|
+
<version>1.0</version>
|
|
6
|
+
<visibility />
|
|
7
7
|
</metadata>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.28",
|
|
4
4
|
"description": "A command line tool for managing Isaac mods written in TypeScript",
|
|
5
5
|
"homepage": "https://isaacscript.github.io/",
|
|
6
6
|
"bugs": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"isaacscript": "./dist/src/main.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/node": "^17.0.
|
|
19
|
+
"@types/node": "^17.0.23",
|
|
20
20
|
"chalk": "4.1.2",
|
|
21
21
|
"command-exists": "^1.2.9",
|
|
22
22
|
"dotenv": "^16.0.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"source-map-support": "^0.5.21",
|
|
32
32
|
"sync-directory": "^4.0.12",
|
|
33
33
|
"ts-node": "^10.7.0",
|
|
34
|
-
"typescript": "^4.6.
|
|
35
|
-
"typescript-to-lua": "^1.4.
|
|
34
|
+
"typescript": "^4.6.3",
|
|
35
|
+
"typescript-to-lua": "^1.4.2",
|
|
36
36
|
"update-notifier": "^5.1.0",
|
|
37
37
|
"yaml": "^1.10.2",
|
|
38
38
|
"yargs": "^17.4.0"
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"@types/source-map-support": "^0.5.4",
|
|
46
46
|
"@types/update-notifier": "^5.1.0",
|
|
47
47
|
"@types/yargs": "^17.0.10",
|
|
48
|
-
"isaacscript-lint": "^1.0.
|
|
48
|
+
"isaacscript-lint": "^1.0.95"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import commandExists from "command-exists";
|
|
3
2
|
import path from "path";
|
|
4
|
-
import yaml from "yaml";
|
|
5
3
|
import * as configFile from "../../configFile";
|
|
6
4
|
import {
|
|
7
5
|
GITIGNORE,
|
|
@@ -14,29 +12,24 @@ import {
|
|
|
14
12
|
METADATA_XML_TEMPLATE_PATH,
|
|
15
13
|
PACKAGE_JSON,
|
|
16
14
|
PACKAGE_JSON_TEMPLATE_PATH,
|
|
17
|
-
PROJECT_NAME,
|
|
18
15
|
README_MD,
|
|
19
16
|
README_MD_TEMPLATES_PATH,
|
|
20
17
|
TEMPLATES_STATIC_DIR,
|
|
21
18
|
} from "../../constants";
|
|
22
19
|
import { execShell } from "../../exec";
|
|
23
20
|
import * as file from "../../file";
|
|
24
|
-
import {
|
|
25
|
-
import { GitHubCLIHostsYAML } from "../../types/GitHubCLIHostsYAML";
|
|
26
|
-
import { error, parseSemVer } from "../../utils";
|
|
21
|
+
import { initGitRepository } from "./git";
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
const REQUIRED_GIT_MINOR_VERSION = 30;
|
|
30
|
-
|
|
31
|
-
export async function createMod(
|
|
23
|
+
export function createMod(
|
|
32
24
|
projectName: string,
|
|
33
25
|
projectPath: string,
|
|
34
26
|
createNewDir: boolean,
|
|
35
27
|
modsDirectory: string,
|
|
36
28
|
saveSlot: number,
|
|
29
|
+
gitRemoteURL: string | undefined,
|
|
37
30
|
skipNPMInstall: boolean,
|
|
38
31
|
verbose: boolean,
|
|
39
|
-
):
|
|
32
|
+
): void {
|
|
40
33
|
if (createNewDir) {
|
|
41
34
|
file.makeDir(projectPath, verbose);
|
|
42
35
|
}
|
|
@@ -45,54 +38,40 @@ export async function createMod(
|
|
|
45
38
|
configFile.createFile(projectPath, config, verbose);
|
|
46
39
|
const targetModDirectory = path.join(config.modsDirectory, projectName);
|
|
47
40
|
|
|
48
|
-
|
|
41
|
+
updateNodeModules(projectPath, verbose);
|
|
42
|
+
installNodeModules(projectPath, skipNPMInstall, verbose);
|
|
49
43
|
makeSubdirectories(projectPath, verbose);
|
|
50
44
|
copyStaticFiles(projectPath, verbose);
|
|
51
45
|
copyDynamicFiles(projectName, projectPath, targetModDirectory, verbose);
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
|
|
47
|
+
// Only make the initial commit once all of the files have been copied
|
|
48
|
+
initGitRepository(projectPath, gitRemoteURL, verbose);
|
|
54
49
|
|
|
55
50
|
console.log(`Successfully created mod: ${chalk.green(projectName)}`);
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
projectName: string,
|
|
61
|
-
verbose: boolean,
|
|
62
|
-
) {
|
|
63
|
-
if (!commandExists.sync("git")) {
|
|
64
|
-
console.log(
|
|
65
|
-
'Git does not seem to be installed. (The "git" command is not in the path.) Skipping Git-related things.',
|
|
66
|
-
);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
checkOldGitVersion(verbose);
|
|
71
|
-
|
|
72
|
-
const remoteURL = await getGitRemoteURL(projectName);
|
|
73
|
-
if (remoteURL === "") {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
execShell("git", ["init"], verbose, false, projectPath);
|
|
78
|
-
execShell("git", ["branch", "-M", "main"], verbose, false, projectPath);
|
|
53
|
+
function updateNodeModules(projectPath: string, verbose: boolean) {
|
|
54
|
+
console.log("Finding out the latest versions of the NPM packages...");
|
|
79
55
|
execShell(
|
|
80
|
-
"
|
|
81
|
-
["
|
|
56
|
+
"npx",
|
|
57
|
+
["npm-check-updates", "--upgrade", "--packageFile", "package.json"],
|
|
82
58
|
verbose,
|
|
83
59
|
false,
|
|
84
60
|
projectPath,
|
|
85
61
|
);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function installNodeModules(
|
|
65
|
+
projectPath: string,
|
|
66
|
+
skipNPMInstall: boolean,
|
|
67
|
+
verbose: boolean,
|
|
68
|
+
) {
|
|
69
|
+
if (skipNPMInstall) {
|
|
70
|
+
return;
|
|
95
71
|
}
|
|
72
|
+
|
|
73
|
+
console.log("Installing node modules... (This can take a long time.)");
|
|
74
|
+
execShell("npm", ["install"], verbose, false, projectPath);
|
|
96
75
|
}
|
|
97
76
|
|
|
98
77
|
function makeSubdirectories(projectPath: string, verbose: boolean) {
|
|
@@ -103,7 +82,7 @@ function makeSubdirectories(projectPath: string, verbose: boolean) {
|
|
|
103
82
|
}
|
|
104
83
|
}
|
|
105
84
|
|
|
106
|
-
|
|
85
|
+
/** Copy static files, like ".eslintrc.js", "tsconfig.json", etc. */
|
|
107
86
|
function copyStaticFiles(projectPath: string, verbose: boolean) {
|
|
108
87
|
const staticFileList = file.getDirList(TEMPLATES_STATIC_DIR);
|
|
109
88
|
staticFileList.forEach((fileName: string) => {
|
|
@@ -115,7 +94,7 @@ function copyStaticFiles(projectPath: string, verbose: boolean) {
|
|
|
115
94
|
});
|
|
116
95
|
}
|
|
117
96
|
|
|
118
|
-
|
|
97
|
+
/** Copy files that need to have text replaced inside of them. */
|
|
119
98
|
function copyDynamicFiles(
|
|
120
99
|
projectName: string,
|
|
121
100
|
projectPath: string,
|
|
@@ -171,6 +150,7 @@ function copyDynamicFiles(
|
|
|
171
150
|
const modPath = path.join(projectPath, "mod");
|
|
172
151
|
const destinationPath = path.join(modPath, fileName);
|
|
173
152
|
file.write(destinationPath, metadataXML, verbose);
|
|
153
|
+
execShell("npx", ["prettier", "--write", destinationPath]);
|
|
174
154
|
}
|
|
175
155
|
|
|
176
156
|
// "mod/metadata.vdf"
|
|
@@ -195,145 +175,6 @@ function copyDynamicFiles(
|
|
|
195
175
|
const mainTS = template.replace(/MOD_NAME_TO_REPLACE/g, projectName);
|
|
196
176
|
const destinationPath = path.join(srcPath, fileName);
|
|
197
177
|
file.write(destinationPath, mainTS, verbose);
|
|
178
|
+
execShell("npx", ["prettier", "--write", destinationPath]);
|
|
198
179
|
}
|
|
199
180
|
}
|
|
200
|
-
|
|
201
|
-
function updateNodeModules(projectPath: string, verbose: boolean) {
|
|
202
|
-
console.log("Finding out the latest versions of the NPM packages...");
|
|
203
|
-
execShell(
|
|
204
|
-
"npx",
|
|
205
|
-
["npm-check-updates", "--upgrade", "--packageFile", "package.json"],
|
|
206
|
-
verbose,
|
|
207
|
-
false,
|
|
208
|
-
projectPath,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async function getGitRemoteURL(projectName: string) {
|
|
213
|
-
const guessedRemoteURL = guessRemoteURL(projectName);
|
|
214
|
-
if (guessedRemoteURL !== undefined) {
|
|
215
|
-
const shouldUseGuessedURL = await getInputYesNo(
|
|
216
|
-
`Do you want to use a Git remote URL of: ${chalk.green(
|
|
217
|
-
guessedRemoteURL,
|
|
218
|
-
)}`,
|
|
219
|
-
);
|
|
220
|
-
if (shouldUseGuessedURL) {
|
|
221
|
-
return guessedRemoteURL;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return getInputString(`Paste in the remote Git URL for your project.
|
|
226
|
-
For example, if you have an SSH key, it would be something like:
|
|
227
|
-
${chalk.green("git@github.com:Alice/green-candle.git")}
|
|
228
|
-
If you don't have an SSH key, it would be something like:
|
|
229
|
-
${chalk.green("https://github.com/Alice/green-candle.git")}
|
|
230
|
-
If you don't want to initialize a Git repository for this project, press enter to skip.
|
|
231
|
-
`);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function checkOldGitVersion(verbose: boolean) {
|
|
235
|
-
const [, stdout] = execShell("git", ["--version"], verbose);
|
|
236
|
-
|
|
237
|
-
const outputPrefix = "git version ";
|
|
238
|
-
if (!stdout.startsWith(outputPrefix)) {
|
|
239
|
-
error(
|
|
240
|
-
`Failed to parse the output from the "git --version" command: ${stdout}`,
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const gitVersionString = stdout.slice(outputPrefix.length);
|
|
245
|
-
const [majorVersion, minorVersion] = parseSemVer(gitVersionString);
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
majorVersion >= REQUIRED_GIT_MAJOR_VERSION &&
|
|
249
|
-
minorVersion >= REQUIRED_GIT_MINOR_VERSION
|
|
250
|
-
) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
console.error(`Your Git version is: ${chalk.red(gitVersionString)}`);
|
|
255
|
-
console.error(
|
|
256
|
-
`${PROJECT_NAME} requires a Git version of ${chalk.red(
|
|
257
|
-
`${REQUIRED_GIT_MAJOR_VERSION}.${REQUIRED_GIT_MINOR_VERSION}.0`,
|
|
258
|
-
)} or greater.`,
|
|
259
|
-
);
|
|
260
|
-
console.error(
|
|
261
|
-
`Please upgrade your version of Git before using ${PROJECT_NAME}.`,
|
|
262
|
-
);
|
|
263
|
-
process.exit(1);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function guessRemoteURL(projectName: string) {
|
|
267
|
-
const gitHubUsername = getGitHubUsername();
|
|
268
|
-
if (gitHubUsername === undefined) {
|
|
269
|
-
return undefined;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return `git@github.com:${gitHubUsername}/${projectName}.git`;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function getGitHubUsername() {
|
|
276
|
-
// If the GitHub CLI is installed, we can derive the user's GitHub username
|
|
277
|
-
if (
|
|
278
|
-
!commandExists.sync("gh") ||
|
|
279
|
-
process.env.APPDATA === undefined ||
|
|
280
|
-
process.env.APPDATA === ""
|
|
281
|
-
) {
|
|
282
|
-
return undefined;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const githubCLIHostsPath = path.join(
|
|
286
|
-
process.env.APPDATA,
|
|
287
|
-
"GitHub CLI",
|
|
288
|
-
"hosts.yml",
|
|
289
|
-
);
|
|
290
|
-
if (!file.exists(githubCLIHostsPath)) {
|
|
291
|
-
return undefined;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const configYAMLRaw = file.read(githubCLIHostsPath);
|
|
295
|
-
const configYAML = yaml.parse(configYAMLRaw) as GitHubCLIHostsYAML;
|
|
296
|
-
|
|
297
|
-
const githubCom = configYAML["github.com"];
|
|
298
|
-
if (githubCom === undefined) {
|
|
299
|
-
return undefined;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const { user } = githubCom;
|
|
303
|
-
if (user === "") {
|
|
304
|
-
return undefined;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return user;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function isGitNameAndEmailConfigured(verbose: boolean) {
|
|
311
|
-
const [nameExitStatus] = execShell(
|
|
312
|
-
"git",
|
|
313
|
-
["config", "--global", "user.name"],
|
|
314
|
-
verbose,
|
|
315
|
-
true,
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const [emailExitStatus] = execShell(
|
|
319
|
-
"git",
|
|
320
|
-
["config", "--global", "user.email"],
|
|
321
|
-
verbose,
|
|
322
|
-
true,
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
return nameExitStatus === 0 && emailExitStatus === 0;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function installNodeModules(
|
|
329
|
-
projectPath: string,
|
|
330
|
-
skipNPMInstall: boolean,
|
|
331
|
-
verbose: boolean,
|
|
332
|
-
) {
|
|
333
|
-
if (skipNPMInstall) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
console.log("Installing node modules... (This can take a long time.)");
|
|
338
|
-
execShell("npm", ["install"], verbose, false, projectPath);
|
|
339
|
-
}
|
|
@@ -29,7 +29,7 @@ export async function getProjectPath(
|
|
|
29
29
|
projectName = CURRENT_DIRECTORY_NAME;
|
|
30
30
|
projectPath = CWD;
|
|
31
31
|
createNewDir = false;
|
|
32
|
-
} else if (projectName !==
|
|
32
|
+
} else if (projectName !== undefined) {
|
|
33
33
|
// The project name was specified on the command-line
|
|
34
34
|
projectPath = path.join(CWD, projectName);
|
|
35
35
|
createNewDir = true;
|
|
@@ -48,8 +48,10 @@ export async function getProjectPath(
|
|
|
48
48
|
|
|
49
49
|
function getProjectNameFromCommandLineArgument(
|
|
50
50
|
argv: Record<string, unknown>,
|
|
51
|
-
): string |
|
|
52
|
-
return typeof argv.name === "string" && argv.name !== ""
|
|
51
|
+
): string | undefined {
|
|
52
|
+
return typeof argv.name === "string" && argv.name !== ""
|
|
53
|
+
? argv.name
|
|
54
|
+
: undefined;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
async function getNewProjectName(): Promise<[string, string, boolean]> {
|