isaacscript 1.1.74 → 1.2.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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,9 +16,10 @@
|
|
|
16
16
|
"isaacscript": "./dist/src/main.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@zamiell/typescript-to-lua": "^1.4.0",
|
|
19
20
|
"chalk": "4.1.2",
|
|
20
21
|
"command-exists": "^1.2.9",
|
|
21
|
-
"dotenv": "^
|
|
22
|
+
"dotenv": "^16.0.0",
|
|
22
23
|
"figlet": "^1.5.2",
|
|
23
24
|
"fs-extra": "^10.0.0",
|
|
24
25
|
"isaacscript-tsconfig": "^1.1.8",
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
"source-map-support": "^0.5.21",
|
|
31
32
|
"sync-directory": "^4.0.12",
|
|
32
33
|
"typescript": "^4.5.5",
|
|
33
|
-
"typescript-to-lua": "^1.3.3",
|
|
34
34
|
"update-notifier": "^5.1.0",
|
|
35
35
|
"yaml": "^1.10.2",
|
|
36
36
|
"yargs": "^17.3.1"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/command-exists": "^1.2.0",
|
|
40
40
|
"@types/figlet": "^1.5.4",
|
|
41
41
|
"@types/fs-extra": "^9.0.13",
|
|
42
|
-
"@types/node": "^17.0.
|
|
42
|
+
"@types/node": "^17.0.16",
|
|
43
43
|
"@types/prompt": "^1.1.2",
|
|
44
44
|
"@types/source-map-support": "^0.5.4",
|
|
45
45
|
"@types/update-notifier": "^5.1.0",
|
|
@@ -19,8 +19,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const tstl = __importStar(require("@zamiell/typescript-to-lua"));
|
|
22
23
|
const crypto = __importStar(require("crypto"));
|
|
23
|
-
const tstl = __importStar(require("typescript-to-lua"));
|
|
24
24
|
class CustomPrinter extends tstl.LuaPrinter {
|
|
25
25
|
printStatement(statement) {
|
|
26
26
|
const uuid = crypto.randomUUID();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addCrashDebugStatements.js","sourceRoot":"","sources":["../../../src/plugins/addCrashDebugStatements.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;
|
|
1
|
+
{"version":3,"file":"addCrashDebugStatements.js","sourceRoot":"","sources":["../../../src/plugins/addCrashDebugStatements.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AACnD,+CAAiC;AAIjC,MAAM,aAAc,SAAQ,IAAI,CAAC,UAAU;IACzC,cAAc,CAAC,SAAyB;QACtC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,iBAAiB,GAAG,kCAAkC,IAAI,MAAM,CAAC;QACvE,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE;YACtC,iBAAiB;YACjB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,MAAM,GAAgB;IAC1B,OAAO,EAAE,CACP,OAAmB,EACnB,QAAuB,EACvB,QAAgB,EAChB,IAAe,EACf,EAAE,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;CAChE,CAAC;AAEF,uBAAuB;AACvB,kBAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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,9 +16,10 @@
|
|
|
16
16
|
"isaacscript": "./dist/src/main.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@zamiell/typescript-to-lua": "^1.4.0",
|
|
19
20
|
"chalk": "4.1.2",
|
|
20
21
|
"command-exists": "^1.2.9",
|
|
21
|
-
"dotenv": "^
|
|
22
|
+
"dotenv": "^16.0.0",
|
|
22
23
|
"figlet": "^1.5.2",
|
|
23
24
|
"fs-extra": "^10.0.0",
|
|
24
25
|
"isaacscript-tsconfig": "^1.1.8",
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
"source-map-support": "^0.5.21",
|
|
31
32
|
"sync-directory": "^4.0.12",
|
|
32
33
|
"typescript": "^4.5.5",
|
|
33
|
-
"typescript-to-lua": "^1.3.3",
|
|
34
34
|
"update-notifier": "^5.1.0",
|
|
35
35
|
"yaml": "^1.10.2",
|
|
36
36
|
"yargs": "^17.3.1"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/command-exists": "^1.2.0",
|
|
40
40
|
"@types/figlet": "^1.5.4",
|
|
41
41
|
"@types/fs-extra": "^9.0.13",
|
|
42
|
-
"@types/node": "^17.0.
|
|
42
|
+
"@types/node": "^17.0.16",
|
|
43
43
|
"@types/prompt": "^1.1.2",
|
|
44
44
|
"@types/source-map-support": "^0.5.4",
|
|
45
45
|
"@types/update-notifier": "^5.1.0",
|
package/publish.sh
CHANGED
package/publish_npm.py
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
import pkg_resources
|
|
12
|
+
|
|
13
|
+
if sys.version_info < (3, 0):
|
|
14
|
+
printf("Error: This script requires Python 3.")
|
|
15
|
+
sys.exit(1)
|
|
16
|
+
|
|
17
|
+
# Constants
|
|
18
|
+
VERSION = pkg_resources.get_distribution("publish_npm").version
|
|
19
|
+
DIR = os.getcwd()
|
|
20
|
+
PROJECT_NAME = os.path.basename(DIR)
|
|
21
|
+
PACKAGE_JSON = "package.json"
|
|
22
|
+
PACKAGE_JSON_PATH = os.path.join(DIR, PACKAGE_JSON)
|
|
23
|
+
UPDATE_SCRIPT_NAME = "update.sh"
|
|
24
|
+
UPDATE_SCRIPT_PATH = os.path.join(DIR, UPDATE_SCRIPT_NAME)
|
|
25
|
+
BUILD_SCRIPT_NAME = "build.sh"
|
|
26
|
+
BUILD_SCRIPT_PATH = os.path.join(DIR, BUILD_SCRIPT_NAME)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main():
|
|
30
|
+
args = parse_command_line_arguments()
|
|
31
|
+
check_package_json_exists()
|
|
32
|
+
check_logged_in_to_npm()
|
|
33
|
+
update_dependencies(args)
|
|
34
|
+
|
|
35
|
+
# Before we increment the version number, make sure that the program compiles
|
|
36
|
+
if is_typescript_project():
|
|
37
|
+
printf("Testing to see if the project compiles...")
|
|
38
|
+
compile_typescript()
|
|
39
|
+
|
|
40
|
+
# Increment the version number
|
|
41
|
+
version = get_version_from_package_json()
|
|
42
|
+
if not args.skip_increment:
|
|
43
|
+
version = increment_version(version)
|
|
44
|
+
put_version(version)
|
|
45
|
+
|
|
46
|
+
# Build the program again so that the new version number is included in the compiled code
|
|
47
|
+
if is_typescript_project():
|
|
48
|
+
printf("Re-compiling the project...")
|
|
49
|
+
compile_typescript()
|
|
50
|
+
|
|
51
|
+
git_commit_if_changes(args, version)
|
|
52
|
+
|
|
53
|
+
publish_to_npm()
|
|
54
|
+
|
|
55
|
+
# Done
|
|
56
|
+
printf(f"Published {PROJECT_NAME} version {version} successfully.")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def parse_command_line_arguments():
|
|
60
|
+
parser = argparse.ArgumentParser(
|
|
61
|
+
description="Publish a new version of this package to NPM."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
"-v",
|
|
66
|
+
"--version",
|
|
67
|
+
action="version",
|
|
68
|
+
help="display the version",
|
|
69
|
+
version=VERSION,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"-s",
|
|
74
|
+
"--skip-increment",
|
|
75
|
+
action="store_true",
|
|
76
|
+
help=f'do not increment the version number in the "{PACKAGE_JSON}" file',
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"-u",
|
|
81
|
+
"--skip-update",
|
|
82
|
+
action="store_true",
|
|
83
|
+
help=f'do not update NPM dependencies in the "{PACKAGE_JSON}" file',
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
parser.add_argument(
|
|
87
|
+
"-c",
|
|
88
|
+
"--skip-commit",
|
|
89
|
+
action="store_true",
|
|
90
|
+
help="do not make a commit to the git repository",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
return parser.parse_args()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def check_package_json_exists():
|
|
97
|
+
if not os.path.isfile(PACKAGE_JSON_PATH):
|
|
98
|
+
error(
|
|
99
|
+
f'Failed to find the "{PACKAGE_JSON}" file in the current working directory.'
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def check_logged_in_to_npm():
|
|
104
|
+
completed_process = subprocess.run(
|
|
105
|
+
["npm", "whoami"],
|
|
106
|
+
shell=True,
|
|
107
|
+
stdout=subprocess.DEVNULL,
|
|
108
|
+
stderr=subprocess.DEVNULL,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
if completed_process.returncode != 0:
|
|
112
|
+
error(
|
|
113
|
+
'The "npm whoami" command failed, so you are probably not logged in. Try doing "npm login".'
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def update_dependencies(args):
|
|
118
|
+
if args.skip_update:
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
printf("Updating NPM dependencies...")
|
|
122
|
+
|
|
123
|
+
# Get the hash before we potentially modify the "package.json" file
|
|
124
|
+
before_hash = get_hash_of_package_json()
|
|
125
|
+
|
|
126
|
+
if os.path.isfile(UPDATE_SCRIPT_PATH):
|
|
127
|
+
run_script(UPDATE_SCRIPT_NAME, UPDATE_SCRIPT_PATH)
|
|
128
|
+
else:
|
|
129
|
+
completed_process = subprocess.run(
|
|
130
|
+
[
|
|
131
|
+
"npx",
|
|
132
|
+
"npm-check-updates",
|
|
133
|
+
"--upgrade",
|
|
134
|
+
"--packageFile",
|
|
135
|
+
PACKAGE_JSON,
|
|
136
|
+
"--loglevel",
|
|
137
|
+
"silent",
|
|
138
|
+
],
|
|
139
|
+
shell=True,
|
|
140
|
+
)
|
|
141
|
+
if completed_process.returncode != 0:
|
|
142
|
+
error(
|
|
143
|
+
f'Failed to run the "npm-check-updates" program to update the "{PACKAGE_JSON}" dependencies to the latest versions.'
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
after_hash = get_hash_of_package_json()
|
|
147
|
+
if before_hash != after_hash:
|
|
148
|
+
# The package.json file was modified, so install the new dependencies
|
|
149
|
+
printf("Installing NPM dependencies...")
|
|
150
|
+
completed_process = subprocess.run(["npm", "install", "--silent"], shell=True)
|
|
151
|
+
if completed_process.returncode != 0:
|
|
152
|
+
error('Failed to run "npm install".')
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def get_hash_of_package_json():
|
|
156
|
+
with open(PACKAGE_JSON_PATH, "rb") as file_handle:
|
|
157
|
+
file_hash = hashlib.md5()
|
|
158
|
+
file_contents = file_handle.read()
|
|
159
|
+
file_hash.update(file_contents)
|
|
160
|
+
|
|
161
|
+
return file_hash.hexdigest()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_version_from_package_json():
|
|
165
|
+
with open(PACKAGE_JSON_PATH, "r", encoding="utf8") as file_handle:
|
|
166
|
+
package_json = json.load(file_handle)
|
|
167
|
+
|
|
168
|
+
if "version" not in package_json:
|
|
169
|
+
error(f'Failed to find the version in the "{PACKAGE_JSON_PATH}" file.')
|
|
170
|
+
|
|
171
|
+
return package_json["version"]
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def increment_version(version: str):
|
|
175
|
+
match = re.search(r"(.+\..+\.)(.+)", version)
|
|
176
|
+
if not match:
|
|
177
|
+
error(f"Failed to parse the version number of: {version}")
|
|
178
|
+
version_prefix = match.group(1)
|
|
179
|
+
patch_version = int(match.group(2)) # i.e. the third number
|
|
180
|
+
incremented_patch_version = patch_version + 1
|
|
181
|
+
incremented_version = version_prefix + str(incremented_patch_version)
|
|
182
|
+
|
|
183
|
+
return incremented_version
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def put_version(version: str):
|
|
187
|
+
with open(PACKAGE_JSON_PATH, "r", encoding="utf8") as file_handle:
|
|
188
|
+
package_json = json.load(file_handle)
|
|
189
|
+
|
|
190
|
+
package_json["version"] = version
|
|
191
|
+
|
|
192
|
+
with open(PACKAGE_JSON_PATH, "w", encoding="utf8", newline="\n") as file_handle:
|
|
193
|
+
json.dump(package_json, file_handle, indent=2, separators=(",", ": "))
|
|
194
|
+
file_handle.write("\n")
|
|
195
|
+
|
|
196
|
+
completed_process = subprocess.run(["npx", "sort-package-json"], shell=True)
|
|
197
|
+
if completed_process.returncode != 0:
|
|
198
|
+
error(f'Failed to sort the "{PACKAGE_JSON}" file.')
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def is_typescript_project():
|
|
202
|
+
with open(
|
|
203
|
+
PACKAGE_JSON_PATH,
|
|
204
|
+
"r",
|
|
205
|
+
encoding="utf8",
|
|
206
|
+
) as file_handle:
|
|
207
|
+
package_json = json.load(file_handle)
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
"dependencies" in package_json and "typescript" in package_json["dependencies"]
|
|
211
|
+
) or (
|
|
212
|
+
"devDependencies" in package_json
|
|
213
|
+
and "typescript" in package_json["devDependencies"]
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def compile_typescript():
|
|
218
|
+
if os.path.isfile(BUILD_SCRIPT_PATH):
|
|
219
|
+
run_script(BUILD_SCRIPT_NAME, BUILD_SCRIPT_PATH)
|
|
220
|
+
else:
|
|
221
|
+
completed_process = subprocess.run(["rm", "-rf", "dist"], shell=True)
|
|
222
|
+
if completed_process.returncode != 0:
|
|
223
|
+
error('Failed to remove the "dist" directory.')
|
|
224
|
+
|
|
225
|
+
completed_process = subprocess.run(["npx", "tsc"], shell=True)
|
|
226
|
+
if completed_process.returncode != 0:
|
|
227
|
+
error('Failed to build the project with "npx tsc".')
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def git_commit_if_changes(args, version):
|
|
231
|
+
if args.skip_commit:
|
|
232
|
+
return
|
|
233
|
+
|
|
234
|
+
# Check to see if this is a git repository
|
|
235
|
+
completed_process = subprocess.run(
|
|
236
|
+
["git", "status"],
|
|
237
|
+
stdout=subprocess.DEVNULL,
|
|
238
|
+
stderr=subprocess.DEVNULL,
|
|
239
|
+
)
|
|
240
|
+
if completed_process.returncode != 0:
|
|
241
|
+
error("This is not a git repository.")
|
|
242
|
+
|
|
243
|
+
# Check to see if there are any changes
|
|
244
|
+
# https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
|
|
245
|
+
completed_process = subprocess.run(["git", "diff-index", "--quiet", "HEAD", "--"])
|
|
246
|
+
changes_to_existing_files = completed_process.returncode != 0
|
|
247
|
+
|
|
248
|
+
# Check to see if there are any untracked files
|
|
249
|
+
# https://stackoverflow.com/questions/11021287/git-detect-if-there-are-untracked-files-quickly
|
|
250
|
+
completed_process = subprocess.run(
|
|
251
|
+
["git", "ls-files", "--other", "--directory", "--exclude-standard"],
|
|
252
|
+
stdout=subprocess.PIPE,
|
|
253
|
+
)
|
|
254
|
+
if completed_process.returncode != 0:
|
|
255
|
+
error("Failed to git ls-files.")
|
|
256
|
+
git_output = completed_process.stdout.decode("utf-8")
|
|
257
|
+
untracked_files_exist = git_output is not None and git_output.strip() != ""
|
|
258
|
+
|
|
259
|
+
if not changes_to_existing_files and not untracked_files_exist:
|
|
260
|
+
printf("There are no changes to push to git.")
|
|
261
|
+
return
|
|
262
|
+
|
|
263
|
+
# Commit to the repository
|
|
264
|
+
printf("Committing to the Git repository...")
|
|
265
|
+
completed_process = subprocess.run(["git", "add", "-A"])
|
|
266
|
+
if completed_process.returncode != 0:
|
|
267
|
+
error("Failed to git add.")
|
|
268
|
+
completed_process = subprocess.run(["git", "commit", "-m", version])
|
|
269
|
+
if completed_process.returncode != 0:
|
|
270
|
+
error("Failed to git commit.")
|
|
271
|
+
completed_process = subprocess.run(["git", "pull", "--rebase"])
|
|
272
|
+
if completed_process.returncode != 0:
|
|
273
|
+
error("Failed to git pull.")
|
|
274
|
+
completed_process = subprocess.run(["git", "push"])
|
|
275
|
+
if completed_process.returncode != 0:
|
|
276
|
+
error("Failed to git push.")
|
|
277
|
+
|
|
278
|
+
printf(f"Pushed a commit to git for version: {version}")
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def publish_to_npm():
|
|
282
|
+
printf("Publishing to NPM...")
|
|
283
|
+
completed_process = subprocess.run(
|
|
284
|
+
[
|
|
285
|
+
"npm",
|
|
286
|
+
"publish",
|
|
287
|
+
"--access",
|
|
288
|
+
"public",
|
|
289
|
+
],
|
|
290
|
+
shell=True,
|
|
291
|
+
)
|
|
292
|
+
if completed_process.returncode != 0:
|
|
293
|
+
error("Failed to npm publish.")
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def error(msg):
|
|
297
|
+
printf(f"Error: {msg}")
|
|
298
|
+
sys.exit(1)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def run_script(script_name, script_path: str):
|
|
302
|
+
completed_process = subprocess.run(
|
|
303
|
+
["bash", script_path],
|
|
304
|
+
shell=True,
|
|
305
|
+
capture_output=True,
|
|
306
|
+
)
|
|
307
|
+
if completed_process.returncode != 0:
|
|
308
|
+
error_script(completed_process, script_name)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def error_script(completed_process: subprocess.CompletedProcess, script_path: str):
|
|
312
|
+
msg = f'Failed to run the "{script_path}" script with return code {completed_process.returncode}'
|
|
313
|
+
stdout = completed_process.stdout.decode().strip()
|
|
314
|
+
stderr = completed_process.stderr.decode().strip()
|
|
315
|
+
if stdout != "" or stderr != "":
|
|
316
|
+
msg += ":\n"
|
|
317
|
+
if stdout != "":
|
|
318
|
+
msg += stdout
|
|
319
|
+
if stderr != "":
|
|
320
|
+
msg += stderr
|
|
321
|
+
else:
|
|
322
|
+
msg += "."
|
|
323
|
+
error(msg)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def printf(*args):
|
|
327
|
+
print(*args, flush=True)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
if __name__ == "__main__":
|
|
331
|
+
main()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as tstl from "@zamiell/typescript-to-lua";
|
|
1
2
|
import * as crypto from "crypto";
|
|
2
3
|
import { SourceNode } from "source-map";
|
|
3
4
|
import * as ts from "typescript";
|
|
4
|
-
import * as tstl from "typescript-to-lua";
|
|
5
5
|
|
|
6
6
|
class CustomPrinter extends tstl.LuaPrinter {
|
|
7
7
|
printStatement(statement: tstl.Statement): SourceNode {
|