create-windowless-app 10.5.0 → 11.0.0

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/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  ![visitors](https://visitor-badge.glitch.me/badge?page_id=yoavain.create-windowless-app)
14
14
  ![Downloads](https://img.shields.io/npm/dm/create-windowless-app.svg)
15
15
 
16
- Create a windowless NodeJS app.
16
+ Create a windowless Node.js app.
17
17
 
18
18
  You can also start from this template repository [create-windowless-app-template](https://github.com/yoavain/create-windowless-app-template)
19
19
 
@@ -22,8 +22,9 @@ If something doesn't work, please [file an issue](https://github.com/yoavain/cre
22
22
 
23
23
 
24
24
  Pre-Requisites for template to work:
25
- * `NodeJS` version `14.17.0` or higher
25
+ * `NodeJS` version `20.0.0` or higher
26
26
  * `MSBuild.exe` must be in the PATH environment variable
27
+ * `signtool` must be in the PATH environment variable
27
28
 
28
29
  ## Quick Overview
29
30
 
@@ -69,6 +70,7 @@ create-windowless-app creates the following files:
69
70
  my-app
70
71
  ├── node_modules
71
72
  ├── package.json
73
+ ├── sea-config.json
72
74
  ├── tsconfig.json
73
75
  ├── tsconfig.build.json
74
76
  ├── webpack.config.js
@@ -97,7 +99,7 @@ Then you can find in your my-app\dist folder the following files:
97
99
  <img src='https://raw.githubusercontent.com/yoavain/create-windowless-app/main/resources/docs/dist.png' width='157' alt='dist files'>
98
100
  </p>
99
101
 
100
- * *my-app.exe* is the compiled app, with NodeJS bundled (using [nexe](https://github.com/nexe/nexe))
102
+ * *my-app.exe* is the compiled app, with Node.js bundled (using [Single Executable Applications](https://nodejs.org/api/single-executable-applications.html))
101
103
  * *my-app-launcher.exe* is the compiled launcher.cs file that executes my-app.exe without a console window
102
104
  * *snoretoast-x64.exe* allows windows notification (using [node-notifier](https://github.com/mikaelbr/node-notifier))
103
105
  * *my-app.log* will be generated on first run (using [winston logger](https://github.com/winstonjs/winston))
@@ -110,9 +112,7 @@ create-windowless-app <project-directory> [options]
110
112
  Options:
111
113
  --no-typescript use javascript rather than typescript
112
114
  --no-husky do not install husky pre-commit hook for building launcher
113
- --skip-install writes dependencies to package.json without installing them
114
115
  --icon <icon> override default launcher icon file
115
- --node-version <nodeVersion> override node version to bundle
116
116
 
117
117
  --interactive interactive mode
118
118
 
@@ -121,12 +121,12 @@ Only <project-directory> is required.
121
121
 
122
122
  ## Why?
123
123
 
124
- NodeJS does not have a native windowless mode (like java has javaw).
124
+ Node.js does not have a native windowless mode (like java has javaw).
125
125
  Sometimes, you want to run an app as a scheduled task that runs in the background, or run a long task (i.e. a server) but do not want a console that must always be open.
126
- Best solution I could find is using a script that executes the NodeJS in windowless mode
126
+ Best solution I could find is using a script that executes the Node.js in windowless mode
127
127
 
128
128
  This package comes to do the following:
129
- 1) Compile a NodeJS (javascript/typescript) project into an *.exe file bundled with NodeJS, so no installation is needed
129
+ 1) Compile a Node.js (javascript/typescript) project into an *.exe file bundled with Node.js, so no installation is needed
130
130
  2) Compile a C# launcher that executes the compiled project, in windowless mode
131
131
 
132
132
  ## Template project
@@ -138,5 +138,5 @@ The "Hello World" template is a POC containing 2 features you might want when ru
138
138
  The template project build script does the following things
139
139
  1) Compiles TypeScript to JavaScript (if in a TypeScript template)
140
140
  2) Runs WebPack to bundle all JavaScript into a single file, and copy binary files into the "dist" folder
141
- 3) Runs nexe to compile the single WebPack JavaScript output file to an exe file bundled with NodeJS (currently, NodeJS version 14.15.3 is the latest version supplied by nexe)
141
+ 3) Runs Node's single executable applications scripts to compile the single WebPack JavaScript output file to an exe file bundled with Node.js (Currently experimental in Node.js 20)
142
142
 
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkNodeRuntimeVersion = void 0;
4
+ const MIN_MAJOR_VERSION = 20;
5
+ const MIN_MINOR_VERSION = 0;
6
+ const checkNodeRuntimeVersion = () => {
7
+ const currentNodeVersion = process.versions.node;
8
+ const semver = currentNodeVersion.split(".");
9
+ const major = Number(semver[0]);
10
+ const minor = Number(semver[1]);
11
+ if (Number.isNaN(major) || Number.isNaN(minor) || major < MIN_MAJOR_VERSION || (major === MIN_MAJOR_VERSION && minor < MIN_MINOR_VERSION)) {
12
+ console.error(`You are running NodeJS ${currentNodeVersion}.\nCreate Windowless App requires NodeJS ${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION} or higher.\nPlease update your version of Node.`);
13
+ process.exit(1);
14
+ }
15
+ };
16
+ exports.checkNodeRuntimeVersion = checkNodeRuntimeVersion;
package/dist/cliParser.js CHANGED
@@ -20,10 +20,11 @@ const yargs_1 = __importDefault(require("yargs"));
20
20
  const helpers_1 = require("yargs/helpers");
21
21
  const interactive_1 = require("./interactive");
22
22
  const validation_1 = require("./validation");
23
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
23
24
  const packageJson = require(`../${createWindowlessAppUtils_1.PACKAGE_JSON_FILENAME}`);
24
25
  const validateInput = (argv) => {
25
26
  if (argv.icon && !(0, fs_extra_1.pathExistsSync)(argv.icon)) {
26
- console.log(`Cannot find icon in ${chalk_1.default.red(argv.icon)}. Switching to ${chalk_1.default.green("default")} icon.`);
27
+ console.warn(`Cannot find icon in ${chalk_1.default.red(argv.icon)}. Switching to ${chalk_1.default.green("default")} icon.`);
27
28
  delete argv.icon;
28
29
  }
29
30
  return argv;
@@ -57,21 +58,11 @@ const parseCommand = (argv) => __awaiter(void 0, void 0, void 0, function* () {
57
58
  type: "boolean",
58
59
  description: "install husky pre-commit hook for building launcher",
59
60
  default: true
60
- })
61
- .option("skip-install", {
62
- alias: "s",
63
- type: "boolean",
64
- description: "write dependencies to package.json without installing"
65
61
  })
66
62
  .option("icon", {
67
63
  alias: "c",
68
64
  type: "string",
69
65
  description: "override default launcher icon file"
70
- })
71
- .option("node-version", {
72
- alias: "n",
73
- type: "string",
74
- description: "override node version to bundle"
75
66
  })
76
67
  .check(({ projectName, interactive, help }) => {
77
68
  if (projectName && typeof (0, validation_1.validateProjectNameInput)(projectName) === "string") {
@@ -97,9 +88,7 @@ const parseCommand = (argv) => __awaiter(void 0, void 0, void 0, function* () {
97
88
  verbose: command.verbose,
98
89
  typescript: command.typescript,
99
90
  husky: command.husky,
100
- skipInstall: command["skip-install"],
101
- icon: command.icon,
102
- nodeVersion: command["node-version"]
91
+ icon: command.icon
103
92
  };
104
93
  }
105
94
  return programConfig;
package/dist/consts.js CHANGED
@@ -9,12 +9,12 @@ exports.consts = {
9
9
  devDependencies: [
10
10
  "fs-extra",
11
11
  "jest",
12
- "nexe",
13
12
  "webpack",
14
13
  "webpack-cli",
15
14
  "copy-webpack-plugin",
16
15
  "rimraf",
17
- "cross-spawn"
16
+ "cross-spawn",
17
+ "postject"
18
18
  ],
19
19
  huskyDependencies: [
20
20
  "husky"
@@ -22,7 +22,7 @@ exports.consts = {
22
22
  tsDevDependencies: [
23
23
  "@types/jest",
24
24
  "@types/node",
25
- "@tsconfig/node14",
25
+ "@tsconfig/node20",
26
26
  "@types/node-notifier",
27
27
  "@types/winston",
28
28
  "ts-loader",
@@ -53,6 +53,7 @@ exports.consts = {
53
53
  ],
54
54
  knownGeneratedFiles: [
55
55
  "package.json",
56
+ "sea-config.json",
56
57
  "webpack.config.js",
57
58
  "tsconfig.json",
58
59
  "tsconfig.build.json",
@@ -35,168 +35,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.createWindowlessApp = exports.buildLauncher = void 0;
38
+ exports.createWindowlessApp = void 0;
39
39
  const chalk_1 = __importDefault(require("chalk"));
40
40
  const path = __importStar(require("path"));
41
41
  const fs_extra_1 = require("fs-extra");
42
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
43
42
  const launcherCompiler_1 = require("./launcherCompiler");
44
43
  const consts_1 = require("./consts");
45
44
  const createWindowlessAppUtils_1 = require("./createWindowlessAppUtils");
46
- const fileUtils_1 = require("./fileUtils");
47
45
  const nodeUtils_1 = require("./nodeUtils");
48
46
  const cliParser_1 = require("./cliParser");
49
- // TypeScript
50
- const tsWebpackConfigResourceLocation = "../templates/typescript/webpack.config.ts";
51
- const tsConfigBuildResourceLocation = "../templates/typescript/tsconfig.build.json";
52
- const tsConfigResourceLocation = "../templates/typescript/tsconfig.json";
53
- const tsIndexResourceLocation = "../templates/typescript/src/index.ts";
54
- const tsLauncherCompilerLocation = "../templates/typescript/launcher/launcherCompiler.ts";
55
- // JavaScript
56
- const jsWebpackConfigResourceLocation = "../templates/javascript/webpack.config.js";
57
- const jsIndexResourceLocation = "../templates/javascript/src/index.js";
58
- const jsLauncherCompilerLocation = "../templates/javascript/launcher/launcherCompiler.js";
59
- // Launcher Source
60
- const launcherSrcResourceLocation = "../templates/common/src/launcher.cs";
61
- const launcherSrcModifiedLocation = "launcher/launcher.cs";
62
- const launcherProjResourceLocation = "../templates/common/launcher.csproj";
63
- const launcherProjModifiedLocation = "launcher/launcher.csproj";
64
- // Default icon location
65
- const defaultLauncherIconLocation = "../templates/common/resources/windows-launcher.ico";
66
- // Husky config file
67
- const huskyConfigFileLocation = "../templates/common/husky/pre-commit";
68
- const install = (root, dependencies, isDev, programConfig) => __awaiter(void 0, void 0, void 0, function* () {
69
- const { verbose, skipInstall } = programConfig;
70
- if (!skipInstall) {
71
- const command = "npm";
72
- const args = ["install", isDev ? "--save-dev" : "--save", "--save-exact", "--loglevel", "error"].concat(dependencies);
73
- if (verbose) {
74
- args.push("--verbose");
75
- }
76
- console.log(`Installing ${chalk_1.default.green(isDev ? "dev dependencies" : "dependencies")}.`);
77
- console.log();
78
- cross_spawn_1.default.sync(command, args, { stdio: "inherit" });
79
- }
80
- else {
81
- console.log(`Adding ${chalk_1.default.green(isDev ? "dev dependencies" : "dependencies")} to package.json (skipping installation)`);
82
- console.log();
83
- const dependenciesObject = dependencies.reduce((acc, dep) => {
84
- var _a, _b, _c;
85
- let depName = dep;
86
- let depVersion = "^x.x.x";
87
- if (dep.lastIndexOf("@") > 0) {
88
- depName = dep.substring(0, dep.lastIndexOf("@"));
89
- const depVersionString = dep.substring(dep.lastIndexOf("@")).split(".");
90
- depVersion = `^${(_a = depVersionString === null || depVersionString === void 0 ? void 0 : depVersionString[0]) !== null && _a !== void 0 ? _a : "x"}.${(_b = depVersionString === null || depVersionString === void 0 ? void 0 : depVersionString[1]) !== null && _b !== void 0 ? _b : "x"}.${(_c = depVersionString === null || depVersionString === void 0 ? void 0 : depVersionString[2]) !== null && _c !== void 0 ? _c : "x"}`;
91
- }
92
- acc[depName] = depVersion;
93
- return acc;
94
- }, {});
95
- (0, createWindowlessAppUtils_1.mergeIntoPackageJson)(root, isDev ? "devDependencies" : "dependencies", dependenciesObject);
96
- }
97
- });
98
- const buildTypeScriptProject = (root, appName, nodeVersion, husky) => {
99
- console.log(`Building project ${chalk_1.default.green("files")}.`);
100
- console.log();
101
- (0, fileUtils_1.writeJson)(path.resolve(root, "tsconfig.build.json"), (0, fileUtils_1.readJsonResource)(tsConfigBuildResourceLocation));
102
- (0, fileUtils_1.writeJson)(path.resolve(root, "tsconfig.json"), (0, fileUtils_1.readJsonResource)(tsConfigResourceLocation));
103
- (0, fileUtils_1.writeFile)(path.resolve(root, "webpack.config.ts"), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(tsWebpackConfigResourceLocation), appName));
104
- (0, fs_extra_1.ensureDirSync)(path.resolve(root, "src"));
105
- (0, fileUtils_1.writeFile)(path.resolve(root, "src", "index.ts"), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(tsIndexResourceLocation), appName));
106
- // Add scripts
107
- const scripts = {
108
- "start": "ts-node src/index.ts",
109
- "type-check": "tsc --build tsconfig.json",
110
- "prewebpack": "rimraf build && rimraf dist",
111
- "webpack": "webpack",
112
- "nexe": (0, createWindowlessAppUtils_1.getNexeCommand)(appName, nodeVersion),
113
- "build": "npm run type-check && npm run webpack && npm run nexe",
114
- "check-msbuild": "ts-node -e \"require(\"\"./launcher/launcherCompiler\"\").checkMsbuildInPath(true)\"",
115
- "rebuild-launcher": "msbuild launcher/launcher.csproj"
116
- };
117
- // Add husky
118
- if (husky) {
119
- scripts["prepare"] = "git config --get core.hookspath || husky install";
120
- scripts["pre-commit"] = `git diff HEAD --exit-code --stat launcher/* || npm run check-msbuild && npm run rebuild-launcher && git add resources/bin/${appName}-launcher.exe`;
121
- (0, fs_extra_1.ensureDirSync)(path.resolve(root, ".husky"));
122
- (0, fileUtils_1.writeFile)(path.resolve(root, ".husky", "pre-commit"), (0, fileUtils_1.readResource)(huskyConfigFileLocation));
123
- }
124
- (0, createWindowlessAppUtils_1.mergeIntoPackageJson)(root, "scripts", scripts);
125
- };
126
- const buildJavaScriptProject = (root, appName, nodeVersion, husky) => {
127
- console.log(`Building project ${chalk_1.default.green("files")}.`);
128
- console.log();
129
- (0, fileUtils_1.writeFile)(path.resolve(root, "webpack.config.js"), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(jsWebpackConfigResourceLocation), appName));
130
- (0, fs_extra_1.ensureDirSync)(path.resolve(root, "src"));
131
- (0, fileUtils_1.writeFile)(path.resolve(root, "src", "index.js"), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(jsIndexResourceLocation), appName));
132
- // Add scripts
133
- const scripts = {
134
- "start": "node src/index.js",
135
- "prewebpack": "rimraf build && rimraf dist",
136
- "webpack": "webpack",
137
- "nexe": (0, createWindowlessAppUtils_1.getNexeCommand)(appName, nodeVersion),
138
- "build": "npm run webpack && npm run nexe",
139
- "check-msbuild": "node -e \"require(\"\"./launcher/launcherCompiler\"\").checkMsbuildInPath(true)\"",
140
- "rebuild-launcher": "msbuild launcher/launcher.csproj"
141
- };
142
- // Add husky
143
- if (husky) {
144
- scripts["prepare"] = "git config --get core.hookspath || husky install";
145
- scripts["pre-commit"] = `git diff HEAD --exit-code --stat launcher/* || npm run check-msbuild && npm run rebuild-launcher && git add resources/bin/${appName}-launcher.exe`;
146
- (0, fs_extra_1.ensureDirSync)(path.resolve(root, ".husky"));
147
- (0, fileUtils_1.writeFile)(path.resolve(root, ".husky", "pre-commit"), (0, fileUtils_1.readResource)(huskyConfigFileLocation));
148
- }
149
- (0, createWindowlessAppUtils_1.mergeIntoPackageJson)(root, "scripts", scripts);
150
- };
151
- const buildLauncher = (root, appName, icon, typescript) => {
152
- console.log(`Building project ${chalk_1.default.green("launcher")}.`);
153
- console.log();
154
- (0, fs_extra_1.ensureDirSync)(path.resolve("launcher"));
155
- (0, fileUtils_1.writeFile)(path.resolve(launcherSrcModifiedLocation), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(launcherSrcResourceLocation), appName));
156
- (0, fileUtils_1.writeFile)(path.resolve(launcherProjModifiedLocation), (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)((0, fileUtils_1.readResource)(launcherProjResourceLocation), appName));
157
- if (typescript) {
158
- (0, fileUtils_1.copyFile)(path.resolve(__dirname, tsLauncherCompilerLocation), path.resolve(root, "launcher", "launcherCompiler.ts"));
159
- }
160
- else {
161
- (0, fileUtils_1.copyFile)(path.resolve(__dirname, jsLauncherCompilerLocation), path.resolve(root, "launcher", "launcherCompiler.js"));
162
- }
163
- // Resolve icon
164
- let iconLocation;
165
- if (icon) {
166
- iconLocation = path.resolve(icon);
167
- console.log(`Building launcher with icon: ${chalk_1.default.green(icon)}.`);
168
- }
169
- else {
170
- iconLocation = path.resolve(__dirname, defaultLauncherIconLocation);
171
- console.log(`Building launcher with ${chalk_1.default.green("default")} icon.`);
172
- }
173
- (0, fileUtils_1.copyFile)(iconLocation, path.resolve(root, "launcher", "launcher.ico"));
174
- return (0, launcherCompiler_1.compileLauncher)();
175
- };
176
- exports.buildLauncher = buildLauncher;
47
+ const packageJson_1 = require("./packageJson");
48
+ const dependencies_1 = require("./dependencies");
49
+ const files_1 = require("./files");
177
50
  const run = (root, appName, originalDirectory, programConfig) => __awaiter(void 0, void 0, void 0, function* () {
178
- const { typescript, husky, icon, nodeVersion } = programConfig;
179
- const dependencies = [...consts_1.consts.dependencies];
180
- const devDependencies = [...consts_1.consts.devDependencies];
181
- if (typescript) {
182
- devDependencies.push(...consts_1.consts.tsDevDependencies);
183
- }
184
- if (husky) {
185
- devDependencies.push(...consts_1.consts.huskyDependencies);
186
- }
51
+ const { typescript, husky, icon, verbose } = programConfig;
187
52
  try {
188
- yield install(root, dependencies, false, programConfig);
189
- yield install(root, devDependencies, true, programConfig);
190
- const checkedNodeVersion = yield (0, nodeUtils_1.checkNodeVersion)(nodeVersion);
191
- if (typescript) {
192
- buildTypeScriptProject(root, appName, checkedNodeVersion, husky);
193
- }
194
- else {
195
- buildJavaScriptProject(root, appName, checkedNodeVersion, husky);
196
- }
53
+ const dependenciesManager = new dependencies_1.DependenciesManager(typescript, husky);
54
+ yield dependenciesManager.installAll(verbose);
55
+ const fileManager = new files_1.FileManager(root, appName, typescript, husky, icon);
56
+ yield fileManager.copyTemplate();
197
57
  // Launcher
198
58
  (0, fs_extra_1.ensureDirSync)(path.resolve(root, "resources", "bin"));
199
- yield (0, exports.buildLauncher)(root, appName, icon, typescript);
59
+ yield (0, launcherCompiler_1.compileLauncher)();
200
60
  console.log("Done");
201
61
  }
202
62
  catch (reason) {
@@ -233,8 +93,8 @@ const run = (root, appName, originalDirectory, programConfig) => __awaiter(void
233
93
  process.exit(1);
234
94
  }
235
95
  });
236
- const createApp = (programConfig) => {
237
- const { projectName } = programConfig;
96
+ const createApp = (programConfig) => __awaiter(void 0, void 0, void 0, function* () {
97
+ const { projectName, typescript, husky } = programConfig;
238
98
  const root = path.resolve(projectName);
239
99
  const appName = path.basename(root);
240
100
  (0, createWindowlessAppUtils_1.checkAppName)(appName);
@@ -244,20 +104,28 @@ const createApp = (programConfig) => {
244
104
  }
245
105
  console.log(`Creating a new windowless app in ${chalk_1.default.green(root)}.`);
246
106
  console.log();
247
- const packageJson = {
248
- name: appName,
249
- version: "0.1.0",
250
- private: true,
251
- main: "_build/index.js"
252
- };
253
- (0, fileUtils_1.writeJson)(path.join(root, "package.json"), packageJson);
254
107
  const originalDirectory = process.cwd();
255
108
  process.chdir(root);
256
109
  if (!(0, nodeUtils_1.checkThatNpmCanReadCwd)()) {
110
+ process.chdir(originalDirectory);
257
111
  process.exit(1);
258
112
  }
259
- return run(root, appName, originalDirectory, programConfig);
260
- };
113
+ try {
114
+ // package.json
115
+ const packageJson = new packageJson_1.PackageJsonBuilder(appName);
116
+ if (!typescript) {
117
+ packageJson.withJavaScript();
118
+ }
119
+ if (husky) {
120
+ packageJson.withHusky();
121
+ }
122
+ (0, files_1.writeJson)(path.join(root, "package.json"), packageJson.build());
123
+ yield run(root, appName, originalDirectory, programConfig);
124
+ }
125
+ finally {
126
+ process.chdir(originalDirectory);
127
+ }
128
+ });
261
129
  const createWindowlessApp = (argv) => __awaiter(void 0, void 0, void 0, function* () {
262
130
  const programConfig = yield (0, cliParser_1.parseCommand)(argv);
263
131
  if (programConfig.projectName) {
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.replaceAppNamePlaceholder = exports.mergeIntoPackageJson = exports.getNexeCommand = exports.checkAppName = exports.isSafeToCreateProjectIn = exports.PACKAGE_JSON_FILENAME = void 0;
6
+ exports.replaceAppNamePlaceholder = exports.checkAppName = exports.isSafeToCreateProjectIn = exports.PACKAGE_JSON_FILENAME = void 0;
7
7
  const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const fileUtils_1 = require("./fileUtils");
11
10
  const consts_1 = require("./consts");
12
11
  const fs_extra_1 = require("fs-extra");
13
12
  // These files should be allowed to remain on a failed install, but then silently removed during the next create.
@@ -73,27 +72,7 @@ const checkAppName = (appName) => {
73
72
  }
74
73
  };
75
74
  exports.checkAppName = checkAppName;
76
- const getNexeCommand = (appName, nodeVersion) => {
77
- return `nexe -t ${nodeVersion} -o dist/${appName}.exe`;
78
- };
79
- exports.getNexeCommand = getNexeCommand;
80
- const mergeIntoPackageJson = (root, field, data) => {
81
- const packageJsonPath = path_1.default.resolve(root, exports.PACKAGE_JSON_FILENAME);
82
- const packageJson = (0, fileUtils_1.readJsonFile)(packageJsonPath);
83
- if (Array.isArray(data)) {
84
- const list = (packageJson[field] || []).concat(data).reduce((acc, cur) => {
85
- acc[cur] = cur;
86
- return acc;
87
- }, {});
88
- packageJson[field] = Object.keys(list);
89
- }
90
- else {
91
- packageJson[field] = Object.assign(packageJson[field] || {}, data);
92
- }
93
- (0, fileUtils_1.writeJson)(packageJsonPath, packageJson);
94
- };
95
- exports.mergeIntoPackageJson = mergeIntoPackageJson;
96
- const replaceAppNamePlaceholder = (str, appName) => {
75
+ const replaceAppNamePlaceholder = (appName, str) => {
97
76
  return str.replace(/##APPNAME##/g, `${appName}`);
98
77
  };
99
78
  exports.replaceAppNamePlaceholder = replaceAppNamePlaceholder;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ var _DependenciesManager_dependencies, _DependenciesManager_devDependencies;
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.DependenciesManager = void 0;
28
+ const chalk_1 = __importDefault(require("chalk"));
29
+ const cross_spawn_1 = __importDefault(require("cross-spawn"));
30
+ const dependencies = [
31
+ "node-notifier",
32
+ "winston"
33
+ ];
34
+ const devDependencies = [
35
+ "fs-extra",
36
+ "jest",
37
+ "webpack",
38
+ "webpack-cli",
39
+ "copy-webpack-plugin",
40
+ "rimraf",
41
+ "cross-spawn",
42
+ "postject"
43
+ ];
44
+ const tsDevDependencies = [
45
+ "@types/jest",
46
+ "@types/node",
47
+ "@tsconfig/node20",
48
+ "@types/node-notifier",
49
+ "@types/winston",
50
+ "ts-loader",
51
+ "ts-node",
52
+ "typescript",
53
+ "@types/cross-spawn"
54
+ ];
55
+ const huskyDependencies = [
56
+ "husky"
57
+ ];
58
+ const install = (dependencies, isDev, verbose) => __awaiter(void 0, void 0, void 0, function* () {
59
+ const command = "npm";
60
+ const args = ["install", isDev ? "--save-dev" : "--save", "--save-exact", "--loglevel", "error"].concat(dependencies);
61
+ if (verbose) {
62
+ args.push("--verbose");
63
+ }
64
+ console.log(`Installing ${chalk_1.default.green(isDev ? "dev dependencies" : "dependencies")}.`);
65
+ console.log();
66
+ cross_spawn_1.default.sync(command, args, { stdio: "inherit" });
67
+ });
68
+ class DependenciesManager {
69
+ constructor(typescript, husky) {
70
+ _DependenciesManager_dependencies.set(this, []);
71
+ _DependenciesManager_devDependencies.set(this, []);
72
+ __classPrivateFieldSet(this, _DependenciesManager_dependencies, dependencies, "f");
73
+ __classPrivateFieldSet(this, _DependenciesManager_devDependencies, devDependencies, "f");
74
+ if (typescript) {
75
+ __classPrivateFieldSet(this, _DependenciesManager_devDependencies, __classPrivateFieldGet(this, _DependenciesManager_devDependencies, "f").concat(tsDevDependencies), "f");
76
+ }
77
+ if (husky) {
78
+ __classPrivateFieldSet(this, _DependenciesManager_devDependencies, __classPrivateFieldGet(this, _DependenciesManager_devDependencies, "f").concat(huskyDependencies), "f");
79
+ }
80
+ }
81
+ installAll(verbose) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ yield install(__classPrivateFieldGet(this, _DependenciesManager_dependencies, "f"), false, verbose);
84
+ yield install(__classPrivateFieldGet(this, _DependenciesManager_devDependencies, "f"), true, verbose);
85
+ });
86
+ }
87
+ }
88
+ exports.DependenciesManager = DependenciesManager;
89
+ _DependenciesManager_dependencies = new WeakMap(), _DependenciesManager_devDependencies = new WeakMap();
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dependenciesManager"), exports);
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ var _FileManager_templatesRoot, _FileManager_targetRoot, _FileManager_typeScript, _FileManager_husky, _FileManager_icon, _FileManager_formatter;
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.FileManager = void 0;
28
+ const _1 = require(".");
29
+ const createWindowlessAppUtils_1 = require("../createWindowlessAppUtils");
30
+ const fs_extra_1 = require("fs-extra");
31
+ const path_1 = __importDefault(require("path"));
32
+ class FileManager {
33
+ constructor(targetRoot, appName, typeScript, husky, icon) {
34
+ _FileManager_templatesRoot.set(this, void 0);
35
+ _FileManager_targetRoot.set(this, void 0);
36
+ _FileManager_typeScript.set(this, void 0);
37
+ _FileManager_husky.set(this, void 0);
38
+ _FileManager_icon.set(this, void 0);
39
+ _FileManager_formatter.set(this, void 0);
40
+ __classPrivateFieldSet(this, _FileManager_templatesRoot, path_1.default.resolve(__dirname, "..", "..", "templates"), "f");
41
+ __classPrivateFieldSet(this, _FileManager_targetRoot, targetRoot, "f");
42
+ __classPrivateFieldSet(this, _FileManager_typeScript, typeScript, "f");
43
+ __classPrivateFieldSet(this, _FileManager_husky, husky, "f");
44
+ __classPrivateFieldSet(this, _FileManager_icon, icon, "f");
45
+ __classPrivateFieldSet(this, _FileManager_formatter, (str) => (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)(appName, str), "f");
46
+ }
47
+ copyTemplate() {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ // common files
50
+ (0, _1.copyFolderRecursiveSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_templatesRoot, "f"), "common"), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f")), __classPrivateFieldGet(this, _FileManager_formatter, "f"));
51
+ // TypeScript or JavaScript
52
+ if (__classPrivateFieldGet(this, _FileManager_typeScript, "f")) {
53
+ (0, _1.copyFolderRecursiveSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_templatesRoot, "f"), "typescript"), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f")), __classPrivateFieldGet(this, _FileManager_formatter, "f"));
54
+ }
55
+ else {
56
+ (0, _1.copyFolderRecursiveSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_templatesRoot, "f"), "javascript"), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f")), __classPrivateFieldGet(this, _FileManager_formatter, "f"));
57
+ }
58
+ // Husky
59
+ if (__classPrivateFieldGet(this, _FileManager_husky, "f")) {
60
+ (0, _1.copyFolderRecursiveSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_templatesRoot, "f"), ".husky"), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f"), ".husky"), __classPrivateFieldGet(this, _FileManager_formatter, "f"));
61
+ }
62
+ // Launcher
63
+ (0, _1.copyFolderRecursiveSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_templatesRoot, "f"), "launcher"), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f"), "launcher"), __classPrivateFieldGet(this, _FileManager_formatter, "f"));
64
+ // Icon
65
+ if (__classPrivateFieldGet(this, _FileManager_icon, "f")) {
66
+ (0, fs_extra_1.copyFileSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_icon, "f")), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f"), "launcher", "launcher.ico"));
67
+ }
68
+ });
69
+ }
70
+ }
71
+ exports.FileManager = FileManager;
72
+ _FileManager_templatesRoot = new WeakMap(), _FileManager_targetRoot = new WeakMap(), _FileManager_typeScript = new WeakMap(), _FileManager_husky = new WeakMap(), _FileManager_icon = new WeakMap(), _FileManager_formatter = new WeakMap();
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.copyFolderRecursiveSync = exports.writeJson = void 0;
7
+ const fs_extra_1 = require("fs-extra");
8
+ const path_1 = __importDefault(require("path"));
9
+ const os_1 = __importDefault(require("os"));
10
+ const writeJson = (fileName, json) => {
11
+ (0, fs_extra_1.writeFileSync)(fileName, JSON.stringify(json, null, 2).replace(/\n/g, os_1.default.EOL) + os_1.default.EOL);
12
+ };
13
+ exports.writeJson = writeJson;
14
+ const TEXT_FORMAT_EXTENSIONS = new Set([".ts", ".js", ".cs", ".json", ".csproj"]);
15
+ function copyFileSyncWithFormatter(sourceFile, targetFile, formatter) {
16
+ console.log(`copyFileSyncWithFormatter from ${sourceFile} to ${targetFile}`);
17
+ if ((0, fs_extra_1.existsSync)(targetFile)) {
18
+ throw new Error(`Target file already exists: ${targetFile}`);
19
+ }
20
+ const ext = path_1.default.extname(sourceFile);
21
+ if (typeof formatter === "function" && TEXT_FORMAT_EXTENSIONS.has(ext.toLowerCase())) {
22
+ console.log(`modifying ${sourceFile}`);
23
+ const data = (0, fs_extra_1.readFileSync)(sourceFile, { encoding: "utf8" });
24
+ (0, fs_extra_1.writeFileSync)(targetFile, formatter(data), { encoding: "utf8" });
25
+ }
26
+ else {
27
+ const data = (0, fs_extra_1.readFileSync)(sourceFile);
28
+ (0, fs_extra_1.writeFileSync)(targetFile, data);
29
+ }
30
+ }
31
+ const copyFolderRecursiveSync = (sourceFolder, targetFolder, formatter) => {
32
+ console.log(`copyFolderRecursiveSync from ${sourceFolder} to ${targetFolder}`);
33
+ if (!(0, fs_extra_1.existsSync)(targetFolder)) {
34
+ console.log(`mkdir ${targetFolder}`);
35
+ (0, fs_extra_1.mkdirSync)(targetFolder);
36
+ }
37
+ else if (!(0, fs_extra_1.lstatSync)(targetFolder).isDirectory()) {
38
+ throw new Error("Target exists and is not a directory.");
39
+ }
40
+ // Copy
41
+ if ((0, fs_extra_1.lstatSync)(sourceFolder).isDirectory()) {
42
+ (0, fs_extra_1.readdirSync)(sourceFolder).forEach((child) => {
43
+ const curSource = path_1.default.join(sourceFolder, child);
44
+ const curTarget = path_1.default.join(targetFolder, child);
45
+ if ((0, fs_extra_1.lstatSync)(curSource).isDirectory()) {
46
+ (0, exports.copyFolderRecursiveSync)(curSource, curTarget, formatter);
47
+ }
48
+ else {
49
+ copyFileSyncWithFormatter(curSource, curTarget, formatter);
50
+ }
51
+ });
52
+ }
53
+ };
54
+ exports.copyFolderRecursiveSync = copyFolderRecursiveSync;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./fileManager"), exports);
18
+ __exportStar(require("./fileUtils"), exports);
@@ -31,18 +31,6 @@ const interactiveMode = () => {
31
31
  name: "husky",
32
32
  default: true
33
33
  },
34
- {
35
- type: "confirm",
36
- message: "Skip NPM Install:",
37
- name: "skipInstall",
38
- default: false
39
- },
40
- {
41
- type: "input",
42
- message: "Node Version:",
43
- name: "nodeVersion",
44
- validate: validation_1.validateNodeVersion
45
- },
46
34
  {
47
35
  type: "confirm",
48
36
  message: "Verbose:",
package/dist/main.js CHANGED
@@ -10,17 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.main = void 0;
13
+ const checkNodeVersion_1 = require("./checkNodeVersion");
13
14
  const launcherCompiler_1 = require("./launcherCompiler");
14
15
  const createWindowlessApp_1 = require("./createWindowlessApp");
15
16
  const main = () => __awaiter(void 0, void 0, void 0, function* () {
16
- const currentNodeVersion = process.versions.node;
17
- const semver = currentNodeVersion.split(".");
18
- const major = Number(semver[0]);
19
- const minor = Number(semver[1]);
20
- if (Number.isNaN(major) || Number.isNaN(minor) || major < 12 || (major === 12 && minor < 20)) {
21
- console.error(`You are running NodeJS ${currentNodeVersion}.\nCreate Windowless App requires NodeJS 12.20 or higher.\nPlease update your version of Node.`);
22
- process.exit(1);
23
- }
17
+ // check minimum node version
18
+ (0, checkNodeVersion_1.checkNodeRuntimeVersion)();
24
19
  // Check for msbuild.exe in %PATH%
25
20
  yield (0, launcherCompiler_1.checkMsbuildInPath)(true);
26
21
  yield (0, createWindowlessApp_1.createWindowlessApp)(process.argv);
package/dist/nodeUtils.js CHANGED
@@ -1,81 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.checkThatNpmCanReadCwd = exports.checkNodeVersion = exports.getWindowsReleases = void 0;
6
+ exports.checkThatNpmCanReadCwd = void 0;
16
7
  const chalk_1 = __importDefault(require("chalk"));
17
- const semver_compare_1 = __importDefault(require("semver-compare"));
18
8
  const cross_spawn_1 = __importDefault(require("cross-spawn"));
19
- const got_1 = __importDefault(require("got"));
20
- const WINDOWS_PREFIX = "windows-x64";
21
- let releases;
22
- const getWindowsReleases = () => __awaiter(void 0, void 0, void 0, function* () {
23
- var _a;
24
- if (!releases) {
25
- const options = {
26
- responseType: "json",
27
- headers: {
28
- "User-Agent": "request"
29
- }
30
- };
31
- const response = yield got_1.default.get("https://api.github.com/repos/nexe/nexe/releases/latest", options);
32
- releases = (response === null || response === void 0 ? void 0 : response.statusCode) === 200 && ((_a = response.body) === null || _a === void 0 ? void 0 : _a.assets.map((asset) => asset.name).filter((name) => name.startsWith(WINDOWS_PREFIX)));
33
- }
34
- return releases;
35
- });
36
- exports.getWindowsReleases = getWindowsReleases;
37
- const checkNodeVersion = (nodeVersion) => __awaiter(void 0, void 0, void 0, function* () {
38
- const windowsPrefixLength = WINDOWS_PREFIX.length + 1;
39
- const windowsVersions = yield (0, exports.getWindowsReleases)();
40
- let nexeNodeVersion;
41
- if (nodeVersion) {
42
- // Find exact
43
- const split = nodeVersion.split(".");
44
- const major = (split.length > 0 && (Number(split[0]) || 0)) || 0;
45
- const minor = (split.length > 1 && (Number(split[1]) || 0)) || 0;
46
- const patch = (split.length > 2 && (Number(split[2]) || 0)) || 0;
47
- const lookupVersion = `${WINDOWS_PREFIX}-${major}.${minor}.${patch}`;
48
- const windowsVersion = windowsVersions && windowsVersions.find((asset) => asset === lookupVersion);
49
- if (windowsVersion) {
50
- if (major <= 14) {
51
- nexeNodeVersion = windowsVersion;
52
- console.log(`Found version ${chalk_1.default.green(nodeVersion)} in nexe`);
53
- }
54
- else {
55
- console.log(`Version ${chalk_1.default.green(nodeVersion)} found in nexe, but known to have issues. Looking for latest working nexe release`);
56
- }
57
- }
58
- else {
59
- console.log(`Can't find node version ${chalk_1.default.red(nodeVersion)} in nexe. Looking for latest nexe release`);
60
- }
61
- }
62
- if (!nexeNodeVersion) {
63
- // Find latest
64
- const latestWindowsVersion = windowsVersions &&
65
- windowsVersions.reduce((acc, cur) => {
66
- const curSemVer = cur.substring(windowsPrefixLength);
67
- const accSemVer = acc.substring(windowsPrefixLength);
68
- if ((0, semver_compare_1.default)(curSemVer, accSemVer) > 0 && (0, semver_compare_1.default)(curSemVer, "15.0.0") < 0) {
69
- acc = cur;
70
- }
71
- return acc;
72
- }, `${WINDOWS_PREFIX}-0.0.0`);
73
- console.log(`Using latest nexe release: ${latestWindowsVersion}`);
74
- nexeNodeVersion = latestWindowsVersion;
75
- }
76
- return nexeNodeVersion;
77
- });
78
- exports.checkNodeVersion = checkNodeVersion;
79
9
  const checkThatNpmCanReadCwd = () => {
80
10
  const cwd = process.cwd();
81
11
  let childOutput = null;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./packageJsonBuilder"), exports);
18
+ __exportStar(require("./packageJsonConsts"), exports);
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _PackageJsonBuilder_appName, _PackageJsonBuilder_typescript, _PackageJsonBuilder_husky;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PackageJsonBuilder = void 0;
16
+ const packageJsonConsts_1 = require("./packageJsonConsts");
17
+ class PackageJsonBuilder {
18
+ constructor(appName) {
19
+ _PackageJsonBuilder_appName.set(this, void 0);
20
+ _PackageJsonBuilder_typescript.set(this, true);
21
+ _PackageJsonBuilder_husky.set(this, false);
22
+ __classPrivateFieldSet(this, _PackageJsonBuilder_appName, appName, "f");
23
+ }
24
+ withJavaScript() {
25
+ __classPrivateFieldSet(this, _PackageJsonBuilder_typescript, false, "f");
26
+ return this;
27
+ }
28
+ withHusky() {
29
+ __classPrivateFieldSet(this, _PackageJsonBuilder_husky, true, "f");
30
+ return this;
31
+ }
32
+ build() {
33
+ let packageJson = (0, packageJsonConsts_1.getPackageJsonBase)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"));
34
+ if (__classPrivateFieldGet(this, _PackageJsonBuilder_typescript, "f")) {
35
+ packageJson = Object.assign(Object.assign({}, packageJson), { scripts: Object.assign(Object.assign({}, packageJson.scripts), (0, packageJsonConsts_1.getTsScripts)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"))) });
36
+ }
37
+ else {
38
+ packageJson = Object.assign(Object.assign({}, packageJson), { scripts: Object.assign(Object.assign({}, packageJson.scripts), (0, packageJsonConsts_1.getJsScripts)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"))) });
39
+ }
40
+ if (__classPrivateFieldGet(this, _PackageJsonBuilder_husky, "f")) {
41
+ packageJson = Object.assign(Object.assign({}, packageJson), { scripts: Object.assign(Object.assign({}, packageJson.scripts), (0, packageJsonConsts_1.getHuskyScripts)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"))) });
42
+ }
43
+ return packageJson;
44
+ }
45
+ }
46
+ exports.PackageJsonBuilder = PackageJsonBuilder;
47
+ _PackageJsonBuilder_appName = new WeakMap(), _PackageJsonBuilder_typescript = new WeakMap(), _PackageJsonBuilder_husky = new WeakMap();
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHuskyScripts = exports.getJsScripts = exports.getTsScripts = exports.getPackageJsonBase = void 0;
4
+ const getPackageJsonBase = (appName) => ({
5
+ name: appName,
6
+ version: "0.1.0",
7
+ private: true,
8
+ main: "_build/index.js",
9
+ scripts: {}
10
+ });
11
+ exports.getPackageJsonBase = getPackageJsonBase;
12
+ const getSingleExecutableApplicationsScripts = (appName) => ({
13
+ "prenode-sea:build-blob": "rimraf _blob && mkdir _blob",
14
+ "node-sea:build-blob": "node --experimental-sea-config sea-config.json",
15
+ "node-sea:copy-node": `node -e "require('fs').copyFileSync(process.execPath, 'dist/${appName}.exe')"`,
16
+ "node-sea:unsign": `signtool remove /s dist/${appName}.exe || echo Warning: signtool not found in "Path"`,
17
+ "node-sea:inject-blob": `postject dist/${appName}.exe NODE_SEA_BLOB _blob\\sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`,
18
+ "node-sea:sign": `signtool sign /fd SHA256 dist/${appName}.exe`,
19
+ "node-sea": "npm run node-sea:build-blob && npm run node-sea:copy-node && npm run node-sea:unsign && npm run node-sea:inject-blob"
20
+ });
21
+ const getTsScripts = (appName) => (Object.assign({ "start": "ts-node src/index.ts", "type-check": "tsc --build tsconfig.json", "prewebpack": "rimraf build && rimraf dist", "webpack": "webpack", "prebuild": "npm run check-node-version", "build": "npm run type-check && npm run webpack && npm run node-sea", "check-node-version": "ts-node -e \"require(\"\"./utils/checkNodeVersion\"\").checkNodeRuntimeVersion()\"", "check-msbuild": "ts-node -e \"require(\"\"./launcher/launcherCompiler\"\").checkMsbuildInPath(true)\"", "rebuild-launcher": "msbuild launcher/launcher.csproj" }, getSingleExecutableApplicationsScripts(appName)));
22
+ exports.getTsScripts = getTsScripts;
23
+ const getJsScripts = (appName) => (Object.assign({ "start": "node src/index.js", "prewebpack": "rimraf build && rimraf dist", "webpack": "webpack", "prebuild": "npm run check-node-version", "build": "npm run webpack && npm run node-sea", "check-node-version": "node -e \"require(\"\"./utils/checkNodeVersion\"\").checkNodeRuntimeVersion()\"", "check-msbuild": "node -e \"require(\"\"./launcher/launcherCompiler\"\").checkMsbuildInPath(true)\"", "rebuild-launcher": "msbuild launcher/launcher.csproj" }, getSingleExecutableApplicationsScripts(appName)));
24
+ exports.getJsScripts = getJsScripts;
25
+ const getHuskyScripts = (appName) => ({
26
+ "prepare": "git config --get core.hookspath || husky install",
27
+ "pre-commit": `git diff HEAD --exit-code --stat launcher/* || npm run check-msbuild && npm run rebuild-launcher && git add resources/bin/${appName}-launcher.exe`
28
+ });
29
+ exports.getHuskyScripts = getHuskyScripts;
@@ -3,16 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateNodeVersion = exports.validateProjectNameInput = void 0;
6
+ exports.validateProjectNameInput = void 0;
7
7
  const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
8
- const semver_1 = __importDefault(require("semver"));
9
8
  const validateProjectNameInput = (value) => {
10
9
  var _a, _b;
11
10
  const result = (0, validate_npm_package_name_1.default)(value);
12
11
  return result.validForNewPackages || ((_a = result === null || result === void 0 ? void 0 : result.errors) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = result === null || result === void 0 ? void 0 : result.warnings) === null || _b === void 0 ? void 0 : _b[0]) || "Invalid project name";
13
12
  };
14
13
  exports.validateProjectNameInput = validateProjectNameInput;
15
- const validateNodeVersion = (value) => {
16
- return !value || !!semver_1.default.valid(value) || "Invalid node version";
17
- };
18
- exports.validateNodeVersion = validateNodeVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-windowless-app",
3
- "version": "10.5.0",
3
+ "version": "11.0.0",
4
4
  "description": "Create a windowless NodeJS app",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "build:no-test": "npm run tsc && npm run add-shebang && npm run package",
16
16
  "build:no-test:ci": "npm run tsc && npm run add-shebang && del package-lock.json && npm prune --omit=dev && npm shrinkwrap && npm run package",
17
17
  "test": "npm run eslint && npm run type-check && npm run jest",
18
- "eslint": "eslint src/ test/ templates/",
18
+ "eslint": "eslint src/ test/ integration_test/ templates/",
19
19
  "eslint:fix": "npm run eslint -- --fix",
20
20
  "type-check": "tsc --build tsconfig.json",
21
21
  "jest": "cross-env FORCE_COLOR=0 jest",
@@ -44,8 +44,8 @@
44
44
  "author": "yoavain",
45
45
  "license": "MIT",
46
46
  "engines": {
47
- "node": ">=14 <19",
48
- "npm": "<=9"
47
+ "node": ">=20",
48
+ "npm": ">=9"
49
49
  },
50
50
  "files": [
51
51
  "dist/**",
@@ -56,16 +56,14 @@
56
56
  },
57
57
  "homepage": "https://github.com/yoavain/create-windowless-app#readme",
58
58
  "devDependencies": {
59
- "@tsconfig/node14": "14.1.0",
60
- "@types/cross-spawn": "6.0.2",
59
+ "@tsconfig/node20": "20.1.1",
60
+ "@types/cross-spawn": "6.0.3",
61
61
  "@types/fs-extra": "11.0.1",
62
62
  "@types/inquirer": "8.2.6",
63
- "@types/jest": "29.5.3",
63
+ "@types/jest": "29.5.4",
64
64
  "@types/mock-fs": "4.13.1",
65
- "@types/node": "18.16.19",
65
+ "@types/node": "20.5.1",
66
66
  "@types/node-notifier": "8.0.2",
67
- "@types/semver": "7.5.0",
68
- "@types/semver-compare": "1.0.1",
69
67
  "@types/validate-npm-package-name": "4.0.0",
70
68
  "@types/winston": "2.4.4",
71
69
  "@typescript-eslint/eslint-plugin": "5.62.0",
@@ -74,35 +72,36 @@
74
72
  "copy-webpack-plugin": "11.0.0",
75
73
  "cross-env": "7.0.3",
76
74
  "del": "6.1.1",
77
- "eslint": "8.44.0",
78
- "eslint-plugin-import": "2.27.5",
79
- "eslint-plugin-jest": "27.2.2",
75
+ "eslint": "8.49.0",
76
+ "eslint-plugin-import": "2.28.1",
77
+ "eslint-plugin-jest": "27.2.3",
80
78
  "eslint-plugin-node": "11.1.0",
81
79
  "eslint-plugin-security": "1.7.1",
82
80
  "global-npm": "0.5.0",
83
81
  "husky": "8.0.3",
84
- "jest": "29.6.1",
85
- "lint-staged": "13.2.3",
82
+ "jest": "29.7.0",
83
+ "lint-staged": "13.3.0",
86
84
  "mock-fs": "5.2.0",
87
85
  "mocked-env": "1.3.5",
88
86
  "node-notifier": "10.0.1",
89
- "prettier": "3.0.0",
87
+ "nyc": "15.1.0",
88
+ "postject": "1.0.0-alpha.6",
89
+ "prettier": "3.0.3",
90
90
  "rimraf": "5.0.1",
91
91
  "tmp-promise": "3.0.3",
92
92
  "ts-jest": "29.1.1",
93
+ "ts-loader": "9.4.4",
93
94
  "ts-node": "10.9.1",
94
- "typescript": "5.1.6",
95
- "webpack": "5.88.1",
96
- "winston": "3.9.0"
95
+ "typescript": "5.2.2",
96
+ "webpack": "5.88.2",
97
+ "webpack-cli": "5.1.4",
98
+ "winston": "3.10.0"
97
99
  },
98
100
  "dependencies": {
99
101
  "chalk": "4.1.2",
100
102
  "cross-spawn": "7.0.3",
101
103
  "fs-extra": "11.1.1",
102
- "got": "11.8.6",
103
- "inquirer": "8.2.5",
104
- "semver": "7.5.4",
105
- "semver-compare": "1.0.0",
104
+ "inquirer": "8.2.6",
106
105
  "validate-npm-package-name": "5.0.0",
107
106
  "yargs": "17.7.2"
108
107
  },
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "_build/index.js",
3
+ "output": "_blob/sea-prep.blob",
4
+ "disableExperimentalSEAWarning": true
5
+ }
@@ -0,0 +1,14 @@
1
+ const MIN_MAJOR_VERSION = 20;
2
+ const MIN_MINOR_VERSION = 0;
3
+
4
+ export const checkNodeRuntimeVersion = () => {
5
+ const currentNodeVersion = process.versions.node;
6
+ const semver = currentNodeVersion.split(".");
7
+ const major = Number(semver[0]);
8
+ const minor = Number(semver[1]);
9
+
10
+ if (Number.isNaN(major) || Number.isNaN(minor) || major < MIN_MAJOR_VERSION || (major === MIN_MAJOR_VERSION && minor < MIN_MINOR_VERSION)) {
11
+ console.error(`You are running Node.js ${currentNodeVersion}.\nYou need at ${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION} or higher.\nPlease update your version of Node.`);
12
+ process.exit(1);
13
+ }
14
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@tsconfig/node14",
2
+ "extends": "@tsconfig/node20",
3
3
  "compilerOptions": {
4
4
  "strict": false,
5
5
  "esModuleInterop": true,
@@ -8,5 +8,5 @@
8
8
  "noEmit": true,
9
9
  "verbatimModuleSyntax": false
10
10
  },
11
- "include": ["./src/**/*", "./webpack.config.ts"]
11
+ "include": ["./src/**/*.ts", "./launcher/**/*.ts", "./utils/**/*.ts", "./webpack.config.ts"]
12
12
  }
@@ -0,0 +1,14 @@
1
+ const MIN_MAJOR_VERSION = 20;
2
+ const MIN_MINOR_VERSION = 0;
3
+
4
+ export const checkNodeRuntimeVersion = () => {
5
+ const currentNodeVersion: string = process.versions.node;
6
+ const semver: string[] = currentNodeVersion.split(".");
7
+ const major: number = Number(semver[0]);
8
+ const minor: number = Number(semver[1]);
9
+
10
+ if (Number.isNaN(major) || Number.isNaN(minor) || major < MIN_MAJOR_VERSION || (major === MIN_MAJOR_VERSION && minor < MIN_MINOR_VERSION)) {
11
+ console.error(`You are running Node.js ${currentNodeVersion}.\nYou need at ${MIN_MAJOR_VERSION}.${MIN_MINOR_VERSION} or higher.\nPlease update your version of Node.`);
12
+ process.exit(1);
13
+ }
14
+ };
package/dist/fileUtils.js DELETED
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.copyFile = exports.writeFile = exports.writeJson = exports.readJsonResource = exports.readResource = exports.readJsonFile = exports.readFile = void 0;
7
- const fs_extra_1 = require("fs-extra");
8
- const path_1 = __importDefault(require("path"));
9
- const os_1 = __importDefault(require("os"));
10
- const readFile = (fileName) => {
11
- return (0, fs_extra_1.readFileSync)(fileName, "utf8");
12
- };
13
- exports.readFile = readFile;
14
- const readJsonFile = (jsonFileName) => {
15
- return JSON.parse((0, exports.readFile)(jsonFileName));
16
- };
17
- exports.readJsonFile = readJsonFile;
18
- const readResource = (resourceRelativePath) => {
19
- return (0, exports.readFile)(path_1.default.resolve(__dirname, resourceRelativePath));
20
- };
21
- exports.readResource = readResource;
22
- const readJsonResource = (resourceRelativePath) => {
23
- return JSON.parse((0, exports.readResource)(resourceRelativePath));
24
- };
25
- exports.readJsonResource = readJsonResource;
26
- const writeJson = (fileName, object) => {
27
- (0, fs_extra_1.writeFileSync)(fileName, JSON.stringify(object, null, 2).replace(/\n/g, os_1.default.EOL) + os_1.default.EOL);
28
- };
29
- exports.writeJson = writeJson;
30
- const writeFile = (fileName, data) => {
31
- (0, fs_extra_1.writeFileSync)(fileName, data.replace(/\r/g, "").replace(/\n/g, os_1.default.EOL));
32
- };
33
- exports.writeFile = writeFile;
34
- const copyFile = (source, destination) => {
35
- (0, fs_extra_1.copyFileSync)(source, destination);
36
- };
37
- exports.copyFile = copyFile;
File without changes
File without changes
File without changes