hackmud-script-manager 0.13.0-a60a7a2 → 0.13.0-c461329
Sign up to get free protection for your applications and to get access to all the features.
- package/.gitattributes +1 -0
- package/.github/workflows/codeql-analysis.yml +39 -0
- package/.github/workflows/publish.yml +42 -0
- package/.vscode/settings.json +6 -0
- package/babel.config.json +6 -0
- package/package.json +12 -21
- package/rollup.config.js +110 -0
- package/scripts/build-package-json.js +36 -0
- package/scripts/jsconfig.json +5 -0
- package/scripts/version-dev.js +25 -0
- package/src/bin/hsm.ts +505 -0
- package/src/constants.json +3 -0
- package/src/generateTypings.ts +116 -0
- package/src/index.ts +19 -0
- package/src/modules.d.ts +5 -0
- package/src/processScript/index.ts +198 -0
- package/src/processScript/minify.ts +529 -0
- package/src/processScript/postprocess.ts +38 -0
- package/src/processScript/preprocess.ts +146 -0
- package/src/processScript/transform.ts +760 -0
- package/src/pull.ts +16 -0
- package/src/push.ts +314 -0
- package/src/syncMacros.ts +52 -0
- package/src/test.ts +59 -0
- package/src/tsconfig.json +20 -0
- package/src/watch.ts +156 -0
- package/tsconfig.json +12 -0
- package/assert-1b7dada8.js +0 -1
- package/bin/hsm.d.ts +0 -2
- package/bin/hsm.js +0 -2
- package/generateTypings.d.ts +0 -2
- package/generateTypings.js +0 -1
- package/index.d.ts +0 -15
- package/index.js +0 -1
- package/processScript/compile.d.ts +0 -17
- package/processScript/compile.js +0 -1
- package/processScript/index.d.ts +0 -30
- package/processScript/index.js +0 -1
- package/processScript/minify.d.ts +0 -7
- package/processScript/minify.js +0 -1
- package/processScript/postProcess.d.ts +0 -2
- package/processScript/postProcess.js +0 -1
- package/processScript/preProcess.d.ts +0 -15
- package/processScript/preProcess.js +0 -1
- package/pull.d.ts +0 -9
- package/pull.js +0 -1
- package/push.d.ts +0 -26
- package/push.js +0 -1
- package/spliceString-2c6f214f.js +0 -1
- package/syncMacros.d.ts +0 -5
- package/syncMacros.js +0 -1
- package/test.d.ts +0 -6
- package/test.js +0 -1
- package/watch.d.ts +0 -14
- package/watch.js +0 -1
package/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.ts linguist-language=TypeScript
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: CodeQL
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- main
|
11
|
+
|
12
|
+
schedule:
|
13
|
+
- cron: 45 7 * * 2
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
analyze:
|
17
|
+
name: Analyze
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
|
20
|
+
strategy:
|
21
|
+
fail-fast: false
|
22
|
+
matrix:
|
23
|
+
language:
|
24
|
+
- javascript
|
25
|
+
|
26
|
+
steps:
|
27
|
+
- name: Checkout repository
|
28
|
+
uses: actions/checkout@v2
|
29
|
+
|
30
|
+
- name: Initialize CodeQL
|
31
|
+
uses: github/codeql-action/init@v1
|
32
|
+
with:
|
33
|
+
languages: ${{ matrix.language }}
|
34
|
+
|
35
|
+
- name: Autobuild
|
36
|
+
uses: github/codeql-action/autobuild@v1
|
37
|
+
|
38
|
+
- name: Perform CodeQL Analysis
|
39
|
+
uses: github/codeql-action/analyze@v1
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Publish
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
release:
|
9
|
+
types:
|
10
|
+
- created
|
11
|
+
|
12
|
+
pull_request:
|
13
|
+
types:
|
14
|
+
- closed
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
publish:
|
18
|
+
name: Publish
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
23
|
+
|
24
|
+
- name: Setup node
|
25
|
+
uses: actions/setup-node@v1
|
26
|
+
with:
|
27
|
+
node-version: 14
|
28
|
+
|
29
|
+
- run: git config --global user.email github-action@users.noreply.github.com
|
30
|
+
- run: git config --global user.name "Github Action"
|
31
|
+
- run: npm ci
|
32
|
+
- run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
|
33
|
+
|
34
|
+
- name: Publish dev
|
35
|
+
if: github.event_name == 'push' || github.event_name == 'pull_request' && github.event.pull_request.merged
|
36
|
+
run: |
|
37
|
+
node scripts/version-dev
|
38
|
+
npm publish --tag dev
|
39
|
+
|
40
|
+
- name: Publish release
|
41
|
+
if: github.event_name == 'release'
|
42
|
+
run: npm publish
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.13.0-
|
3
|
+
"version": "0.13.0-c461329",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -21,26 +21,14 @@
|
|
21
21
|
"bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
|
22
22
|
"license": "GPL-3.0-or-later",
|
23
23
|
"author": "Samual Norman",
|
24
|
-
"files": [
|
25
|
-
"*.d.ts",
|
26
|
-
"*.js",
|
27
|
-
"!*.config.js",
|
28
|
-
"index.cjs",
|
29
|
-
"bin",
|
30
|
-
"processScript"
|
31
|
-
],
|
32
24
|
"main": "index.js",
|
33
|
-
"bin": {
|
34
|
-
"hsm": "bin/hsm.js"
|
35
|
-
},
|
36
25
|
"repository": {
|
37
26
|
"type": "git",
|
38
27
|
"url": "https://github.com/samualtnorman/hackmud-script-manager.git"
|
39
28
|
},
|
40
29
|
"scripts": {
|
41
|
-
"build": "rollup --config && tsc --project src",
|
42
|
-
"dev": "rollup --config --watch"
|
43
|
-
"prepublishOnly": "npm run build"
|
30
|
+
"build": "rm -rf dist && rollup --config && tsc --project src && node scripts/build-package-json && cp LICENSE index.cjs package-lock.json README.md dist",
|
31
|
+
"dev": "rollup --config --watch"
|
44
32
|
},
|
45
33
|
"dependencies": {
|
46
34
|
"@babel/core": "^7.16.0",
|
@@ -68,23 +56,26 @@
|
|
68
56
|
"@babel/plugin-transform-typescript": "^7.16.1",
|
69
57
|
"@babel/traverse": "^7.16.3",
|
70
58
|
"@babel/types": "^7.16.0",
|
59
|
+
"@bloomberg/record-tuple-polyfill": "^0.0.4",
|
60
|
+
"@rollup/plugin-babel": "^5.3.0",
|
61
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
62
|
+
"@rollup/plugin-json": "^4.1.0",
|
63
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
71
64
|
"acorn": "^8.5.0",
|
72
65
|
"chalk": "^4.1.2",
|
73
66
|
"chokidar": "^3.5.2",
|
67
|
+
"prettier": "^2.4.1",
|
68
|
+
"rollup": "^2.60.0",
|
74
69
|
"terser": "^5.10.0"
|
75
70
|
},
|
76
71
|
"devDependencies": {
|
77
72
|
"@babel/preset-env": "^7.16.4",
|
78
73
|
"@babel/preset-typescript": "^7.16.0",
|
79
|
-
"@
|
80
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
81
|
-
"@rollup/plugin-json": "^4.1.0",
|
82
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
83
|
-
"@samual/lib": "^0.2.0-e6a06ca",
|
74
|
+
"@samual/lib": "^0.2.0-27ea8d5",
|
84
75
|
"@types/babel__core": "^7.1.16",
|
85
76
|
"@types/node": "^12.20.37",
|
77
|
+
"@types/prettier": "^2.4.2",
|
86
78
|
"@types/semver": "^7.3.9",
|
87
|
-
"rollup": "^2.60.0",
|
88
79
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
89
80
|
"rollup-plugin-terser": "^7.0.2",
|
90
81
|
"semver": "^7.3.5",
|
package/rollup.config.js
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
import babel from "@rollup/plugin-babel"
|
2
|
+
import commonJS from "@rollup/plugin-commonjs"
|
3
|
+
import json from "@rollup/plugin-json"
|
4
|
+
import nodeResolve from "@rollup/plugin-node-resolve"
|
5
|
+
import fs from "fs"
|
6
|
+
import preserveShebang from "rollup-plugin-preserve-shebang"
|
7
|
+
import { terser } from "rollup-plugin-terser"
|
8
|
+
import packageConfig from "./package.json"
|
9
|
+
|
10
|
+
const { readdir: readDirectory } = fs.promises
|
11
|
+
|
12
|
+
/** @typedef {import("rollup").RollupOptions} RollupOptions */
|
13
|
+
|
14
|
+
const plugins = [
|
15
|
+
babel({
|
16
|
+
babelHelpers: "bundled",
|
17
|
+
extensions: [ ".ts" ]
|
18
|
+
}),
|
19
|
+
commonJS(),
|
20
|
+
json({ preferConst: true }),
|
21
|
+
nodeResolve({ extensions: [ ".ts" ] }),
|
22
|
+
preserveShebang()
|
23
|
+
]
|
24
|
+
|
25
|
+
const external = []
|
26
|
+
|
27
|
+
if ("dependencies" in packageConfig)
|
28
|
+
external.push(...Object.keys(packageConfig.dependencies))
|
29
|
+
|
30
|
+
const sourceDirectory = "src"
|
31
|
+
const findFilesPromise = findFiles(sourceDirectory)
|
32
|
+
|
33
|
+
/** @type {(command: Record<string, unknown>) => Promise<RollupOptions>} */
|
34
|
+
export default async ({ w }) => {
|
35
|
+
if (!w) {
|
36
|
+
plugins.push(terser({
|
37
|
+
ecma: 2019,
|
38
|
+
keep_classnames: true,
|
39
|
+
keep_fnames: true
|
40
|
+
}))
|
41
|
+
} else if ("devDependencies" in packageConfig)
|
42
|
+
external.push(...Object.keys(packageConfig.devDependencies).map(name => new RegExp(`^${name}(?:/|$)`)))
|
43
|
+
|
44
|
+
return {
|
45
|
+
input: Object.fromEntries(
|
46
|
+
(await findFilesPromise)
|
47
|
+
.filter(path => path.endsWith(".ts") && !path.endsWith(".d.ts"))
|
48
|
+
.map(path => [ path.slice(sourceDirectory.length + 1, -3), path ])
|
49
|
+
),
|
50
|
+
output: {
|
51
|
+
dir: "dist",
|
52
|
+
interop: "auto"
|
53
|
+
},
|
54
|
+
plugins,
|
55
|
+
external,
|
56
|
+
preserveEntrySignatures: "allow-extension",
|
57
|
+
treeshake: {
|
58
|
+
moduleSideEffects: "no-external"
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @param path the directory to start recursively finding files in
|
65
|
+
* @param filter either a blacklist or a filter function that returns false to ignore file name
|
66
|
+
* @returns promise that resolves to array of found files
|
67
|
+
* @type {(path: string, filter?: string[] | ((name: string) => boolean)) => Promise<string[]>}
|
68
|
+
*/
|
69
|
+
async function findFiles(path, filter = []) {
|
70
|
+
const paths = []
|
71
|
+
let /** @type {(name: string) => boolean} */ filterFunction
|
72
|
+
|
73
|
+
if (Array.isArray(filter))
|
74
|
+
filterFunction = name => !filter.includes(name)
|
75
|
+
else
|
76
|
+
filterFunction = filter
|
77
|
+
|
78
|
+
for (const dirent of await readDirectory(path, { withFileTypes: true })) {
|
79
|
+
if (!filterFunction(dirent.name))
|
80
|
+
continue
|
81
|
+
|
82
|
+
const direntPath = `${path}/${dirent.name}`
|
83
|
+
|
84
|
+
if (dirent.isDirectory())
|
85
|
+
await findFilesSub(direntPath, filterFunction, paths)
|
86
|
+
else if (dirent.isFile())
|
87
|
+
paths.push(direntPath)
|
88
|
+
}
|
89
|
+
|
90
|
+
return paths
|
91
|
+
}
|
92
|
+
|
93
|
+
async function findFilesSub(path, filterFunction, paths) {
|
94
|
+
const promises = []
|
95
|
+
|
96
|
+
for (const dirent of await readDirectory(path, { withFileTypes: true })) {
|
97
|
+
if (!filterFunction(dirent.name))
|
98
|
+
continue
|
99
|
+
|
100
|
+
const direntPath = `${path}/${dirent.name}`
|
101
|
+
|
102
|
+
if (dirent.isDirectory())
|
103
|
+
promises.push(findFilesSub(direntPath, filterFunction, paths))
|
104
|
+
else if (dirent.isFile())
|
105
|
+
paths.push(direntPath)
|
106
|
+
}
|
107
|
+
|
108
|
+
await Promise.all(promises)
|
109
|
+
return paths
|
110
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import findFiles from "@samual/lib/findFiles"
|
2
|
+
import fs from "fs"
|
3
|
+
|
4
|
+
const { writeFile, readFile } = fs.promises
|
5
|
+
|
6
|
+
;(async () => {
|
7
|
+
const packageConfig = JSON.parse(await readFile("package.json", { encoding: "utf-8" }))
|
8
|
+
|
9
|
+
delete packageConfig.private
|
10
|
+
delete packageConfig.scripts
|
11
|
+
|
12
|
+
packageConfig.bin = {}
|
13
|
+
|
14
|
+
for (let name of await findFiles("dist")) {
|
15
|
+
name = `.${name.slice(4)}`
|
16
|
+
|
17
|
+
if (name.startsWith("./bin/") && name.endsWith(".js")) {
|
18
|
+
packageConfig.bin[name.slice(6, -3)] = name
|
19
|
+
continue
|
20
|
+
}
|
21
|
+
|
22
|
+
if (!name.endsWith(".d.ts"))
|
23
|
+
continue
|
24
|
+
|
25
|
+
name = name.slice(0, -5)
|
26
|
+
|
27
|
+
const nameWithExtension = `${name}.js`
|
28
|
+
|
29
|
+
packageConfig.exports[name] = nameWithExtension
|
30
|
+
|
31
|
+
if (name != "./index" && name.endsWith("/index"))
|
32
|
+
packageConfig.exports[name.slice(0, -6)] = nameWithExtension
|
33
|
+
}
|
34
|
+
|
35
|
+
await writeFile("dist/package.json", JSON.stringify(packageConfig, null, "\t"))
|
36
|
+
})()
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { exec as execute_ } from "child_process"
|
2
|
+
import fs from "fs"
|
3
|
+
import semver from "semver"
|
4
|
+
import { promisify } from "util"
|
5
|
+
|
6
|
+
const { readFile } = fs.promises
|
7
|
+
const execute = promisify(execute_)
|
8
|
+
|
9
|
+
;(async () => {
|
10
|
+
const [ packageJSONFile, { stdout: gitGetHashStdout } ] = await Promise.all([
|
11
|
+
readFile("package.json", { encoding: "utf-8" }),
|
12
|
+
execute("git rev-parse --short HEAD")
|
13
|
+
])
|
14
|
+
|
15
|
+
const { stdout, stderr } = await execute(
|
16
|
+
`npm version ${
|
17
|
+
semver.inc(JSON.parse(packageJSONFile).version, "minor")
|
18
|
+
}-${
|
19
|
+
gitGetHashStdout.trim()
|
20
|
+
}`
|
21
|
+
)
|
22
|
+
|
23
|
+
process.stdout.write(stdout)
|
24
|
+
process.stderr.write(stderr)
|
25
|
+
})()
|