Skip to content

Commit f991586

Browse files
committed
NodeJS wrapper TypeScript based
1 parent dc2d5c3 commit f991586

File tree

10 files changed

+1760
-677
lines changed

10 files changed

+1760
-677
lines changed

.eslintrc.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
env:
2+
amd: false
3+
applescript: false
4+
atomtest: false
5+
browser: true
6+
commonjs: true
7+
embertest: false
8+
es6: true
9+
es2017: true
10+
es2020: true
11+
es2021: true
12+
greasemonkey: false
13+
jasmine: false
14+
jest: false
15+
jquery: false
16+
meteor: false
17+
mocha: false
18+
mongo: false
19+
nashorn: false
20+
node: true
21+
phantomjs: false
22+
prototypejs: false
23+
protractor: false
24+
qunit: false
25+
serviceworker: true
26+
shared-node-browser: true
27+
shelljs: false
28+
webextensions: true
29+
worker: true
30+
extends:
31+
- "eslint:all"
32+
- "plugin:@typescript-eslint/recommended"
33+
parser: "@typescript-eslint/parser"
34+
parserOptions:
35+
ecmaFeatures:
36+
arrowFunctions: true
37+
classes: true
38+
defaultParams: true
39+
destructuring: true
40+
experimentalObjectRestSpread: true
41+
forOf: true
42+
generators: true
43+
globalReturn: false
44+
impliedStrict: true
45+
jsx: false
46+
modules: true
47+
objectLiteralComputedProperties: true
48+
objectLiteralDuplicateProperties: true
49+
objectLiteralShorthandMethods: true
50+
objectLiteralShorthandProperties: true
51+
regexUFlag: true
52+
regexYFlag: true
53+
restParams: true
54+
spread: true
55+
superInFunctions: false
56+
templateStrings: true
57+
unicodeCodePointEscapes: true
58+
ecmaVersion: "latest"
59+
sourceType: "module"
60+
plugins:
61+
- "@typescript-eslint"
62+
- "only-warn"
63+
rules:
64+
array-element-newline:
65+
- "warn"
66+
- "consistent"
67+
arrow-body-style:
68+
- "warn"
69+
- "always"
70+
brace-style:
71+
- "warn"
72+
- "1tbs"
73+
- allowSingleLine: false
74+
capitalized-comments: "off"
75+
complexity: "off"
76+
dot-location: "off"
77+
dot-notation: "off"
78+
eqeqeq:
79+
- "warn"
80+
- "always"
81+
func-names:
82+
- "warn"
83+
- "as-needed"
84+
func-style:
85+
- "warn"
86+
- "declaration"
87+
- allowArrowFunctions: true
88+
function-call-argument-newline:
89+
- "warn"
90+
- "consistent"
91+
function-paren-newline:
92+
- "warn"
93+
- "multiline-arguments"
94+
guard-for-in: "off"
95+
id-length:
96+
- "warn"
97+
- max: 80
98+
min: 1
99+
properties: "always"
100+
indent:
101+
- "warn"
102+
- "tab"
103+
- flatTernaryExpressions: false
104+
ImportDeclaration: 1
105+
MemberExpression: 1
106+
ObjectExpression: 1
107+
outerIIFEBody: 1
108+
SwitchCase: 1
109+
VariableDeclarator: 1
110+
init-declarations: "off"
111+
line-comment-position: "off"
112+
linebreak-style: "off"
113+
lines-around-comment: "off"
114+
lines-between-class-members: "off"
115+
max-classes-per-file: "off"
116+
max-depth: "off"
117+
max-len: "off"
118+
max-lines-per-function: "off"
119+
max-lines: "off"
120+
max-params:
121+
- "warn"
122+
- max: 5
123+
max-statements: "off"
124+
multiline-comment-style: "off"
125+
multiline-ternary:
126+
- "warn"
127+
- "always-multiline"
128+
new-cap: "off"
129+
no-alert: "off"
130+
no-bitwise: "off"
131+
no-case-declarations: "off"
132+
no-console: "off"
133+
no-continue: "off"
134+
no-empty:
135+
- "warn"
136+
- allowEmptyCatch: true
137+
no-extra-parens:
138+
- "warn"
139+
- "all"
140+
- conditionalAssign: false
141+
ignoreJSX: "multi-line"
142+
nestedBinaryExpressions: false
143+
returnAssign: false
144+
no-inline-comments: "off"
145+
no-labels: "off"
146+
no-magic-numbers: "off"
147+
no-mixed-operators:
148+
- "warn"
149+
- allowSamePrecedence: true
150+
no-new: "off"
151+
no-param-reassign: "off"
152+
no-plusplus:
153+
- "warn"
154+
- allowForLoopAfterthoughts: true
155+
no-tabs:
156+
- "warn"
157+
- allowIndentationTabs: true
158+
no-ternary: "off"
159+
no-undefined: "off"
160+
no-var: "off"
161+
no-void: "off"
162+
object-curly-newline:
163+
- "warn"
164+
- consistent: true
165+
multiline: true
166+
object-curly-spacing:
167+
- "warn"
168+
- "always"
169+
object-shorthand:
170+
- "warn"
171+
- "consistent-as-needed"
172+
one-var-declaration-per-line: "off"
173+
one-var: "off"
174+
padded-blocks:
175+
- "warn"
176+
- "never"
177+
prefer-arrow-callback:
178+
- "warn"
179+
- allowNamedFunctions: true
180+
prefer-const: "off"
181+
prefer-destructuring: "off"
182+
prefer-exponentiation-operator: "off"
183+
prefer-rest-params: "off"
184+
quote-props:
185+
- "warn"
186+
- "consistent"
187+
quotes:
188+
- "warn"
189+
- "double"
190+
- allowTemplateLiterals: true
191+
semi:
192+
- "warn"
193+
- "always"
194+
- omitLastInOneLineBlock: false
195+
sort-imports:
196+
- "warn"
197+
- allowSeparatedGroups: false
198+
ignoreCase: true
199+
sort-keys:
200+
- "warn"
201+
- "asc"
202+
- caseSensitive: false
203+
natural: true
204+
sort-vars:
205+
- "warn"
206+
- ignoreCase: true
207+
space-before-function-paren:
208+
- "warn"
209+
- anonymous: "always"
210+
named: "never"
211+
asyncArrow: "always"
212+
spaced-comment: "off"

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ updates:
1515
separator: "/"
1616
rebase-strategy: "disabled"
1717
- package-ecosystem: "npm"
18-
directory: "/nodejs-wrapper-source"
18+
directory: "/"
1919
schedule:
2020
interval: "daily"
2121
time: "00:00"

nodejs-wrapper-source/bundler.js renamed to bundler.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
import { execSync } from "node:child_process";
12
import { existsSync as fsExistsSync } from "node:fs";
2-
import { mkdir as fsMKDir, readdir as fsReadDir, readFile as fsReadFile, rm as fsRemove, writeFile as fsWriteFile } from "node:fs/promises";
3-
import { dirname as pathDirName, join as pathJoin } from "node:path";
3+
import { mkdir as fsMkdir, readdir as fsReaddir, readFile as fsReadFile, rm as fsRm, writeFile as fsWriteFile } from "node:fs/promises";
4+
import { dirname as pathDirname, join as pathJoin } from "node:path";
45
import { fileURLToPath } from "node:url";
56
import ncc from "@vercel/ncc";
6-
const inputDirectoryPath = pathDirName(fileURLToPath(import.meta.url));
7+
const root = pathDirname(fileURLToPath(import.meta.url));
78
const packageFileName = "package.json"
8-
const scriptFileName = "main.js";
9-
const outputDirectoryPath = pathJoin(inputDirectoryPath, "../hugoalh.GitHubActionsToolkit/module/nodejs-wrapper");
9+
const scriptEntryPointFileName = "main.js";
10+
const inputDirectoryPath = pathJoin(root, "temp");
11+
const inputFilePath = pathJoin(inputDirectoryPath, scriptEntryPointFileName);
12+
const outputDirectoryPath = pathJoin(root, "hugoalh.GitHubActionsToolkit", "module", "nodejs-wrapper");
13+
const outputFilePath = pathJoin(outputDirectoryPath, scriptEntryPointFileName);
1014
async function getDirectoryItem(directoryPath, relativeBasePath) {
1115
if (typeof relativeBasePath === "undefined") {
1216
relativeBasePath = directoryPath;
1317
}
1418
try {
1519
let result = [];
16-
for (let item of await fsReadDir(directoryPath, { withFileTypes: true })) {
20+
for (let item of await fsReaddir(directoryPath, { withFileTypes: true })) {
1721
if (item.isDirectory()) {
1822
result.push(...await getDirectoryItem(pathJoin(directoryPath, item.name), relativeBasePath));
1923
} else {
@@ -29,14 +33,15 @@ async function getDirectoryItem(directoryPath, relativeBasePath) {
2933
/* Clean up or initialize output directory (need to await in order to prevent race conditions). */
3034
if (fsExistsSync(outputDirectoryPath)) {
3135
for (let fileName of await getDirectoryItem(outputDirectoryPath)) {
32-
await fsRemove(pathJoin(outputDirectoryPath, fileName), { recursive: true });
36+
await fsRm(pathJoin(outputDirectoryPath, fileName), { recursive: true });
3337
}
3438
} else {
35-
await fsMKDir(outputDirectoryPath, { recursive: true });
39+
await fsMkdir(outputDirectoryPath, { recursive: true });
3640
}
3741

3842
/* Create bundle. */
39-
let { code } = await ncc(pathJoin(inputDirectoryPath, scriptFileName), {
43+
console.log(execSync(`"${pathJoin(root, "node_modules", ".bin", process.platform === "win32" ? "tsc.cmd" : "tsc")}" -p "${pathJoin(root, "tsconfig.json")}"`).toString("utf8"));
44+
let { code } = await ncc(inputFilePath, {
4045
assetBuilds: false,
4146
cache: false,
4247
debugLog: false,
@@ -49,8 +54,8 @@ let { code } = await ncc(pathJoin(inputDirectoryPath, scriptFileName), {
4954
v8cache: false,
5055
watch: false
5156
});
52-
await fsWriteFile(pathJoin(outputDirectoryPath, scriptFileName), code, { encoding: "utf8" });
53-
let packageMeta = JSON.parse(await fsReadFile(pathJoin(inputDirectoryPath, packageFileName), { encoding: "utf8" }));
57+
await fsWriteFile(outputFilePath, code, { encoding: "utf8" });
58+
let packageMeta = JSON.parse(await fsReadFile(pathJoin(root, packageFileName), { encoding: "utf8" }));
5459
delete packageMeta.scripts;
5560
delete packageMeta.dependencies;
5661
delete packageMeta.devDependencies;

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/main.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)