create-windowless-app 11.0.3 → 13.0.6

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
@@ -23,6 +23,7 @@ If something doesn't work, please [file an issue](https://github.com/yoavain/cre
23
23
 
24
24
  Pre-Requisites for template to work:
25
25
  * `NodeJS` version `20.0.0` or higher
26
+ * `npm` version `9.0.0` or higher
26
27
  * `MSBuild.exe` must be in the PATH environment variable
27
28
  * `signtool` must be in the PATH environment variable
28
29
 
@@ -71,19 +72,22 @@ my-app
71
72
  ├── node_modules
72
73
  ├── package.json
73
74
  ├── sea-config.json
74
- ├── tsconfig.json
75
- ├── tsconfig.build.json
76
- ├── webpack.config.js
77
- ├── launcher
75
+ ├── tsconfig.json (TypeScript projects)
76
+ ├── tsconfig.build.json (TypeScript projects)
77
+ ├── webpack.config.ts (TypeScript projects)
78
+ ├── webpack.config.js (JavaScript projects)
79
+ ├── launcher/
78
80
  │ ├── launcher.cs
79
81
  │ ├── launcher.csproj
80
- | ├── launcher.ico
81
- | └── launcherCompiler.ts
82
- ├── resources
83
- │ └── bin
82
+ ├── launcher.ico
83
+ └── launcherCompiler.js (JavaScript) / launcherCompiler.ts (TypeScript)
84
+ ├── resources/
85
+ │ └── bin/
84
86
  │ └── my-app-launcher.exe
85
- └───src
86
- └── index.js
87
+ ├── src/
88
+ └── index.js (JavaScript) / index.ts (TypeScript)
89
+ └── utils/
90
+ └── (utility files)
87
91
  ```
88
92
 
89
93
  No configuration or complicated folder structures, just the files you need to build your app.<br>
@@ -111,8 +115,8 @@ create-windowless-app <project-directory> [options]
111
115
 
112
116
  Options:
113
117
  --no-typescript use javascript rather than typescript
114
- --no-husky do not install husky pre-commit hook for building launcher
115
118
  --icon <icon> override default launcher icon file
119
+ --verbose print additional logs
116
120
 
117
121
  --interactive interactive mode
118
122
 
package/dist/cliParser.js CHANGED
@@ -14,84 +14,94 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.parseCommand = void 0;
16
16
  const chalk_1 = __importDefault(require("chalk"));
17
+ const util_1 = require("util");
17
18
  const createWindowlessAppUtils_1 = require("./createWindowlessAppUtils");
18
- const fs_extra_1 = require("fs-extra");
19
- const yargs_1 = __importDefault(require("yargs"));
20
- const helpers_1 = require("yargs/helpers");
19
+ const fs_1 = require("fs");
21
20
  const interactive_1 = require("./interactive");
22
21
  const validation_1 = require("./validation");
23
- // eslint-disable-next-line @typescript-eslint/no-var-requires
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
24
23
  const packageJson = require(`../${createWindowlessAppUtils_1.PACKAGE_JSON_FILENAME}`);
25
- const validateInput = (argv) => {
26
- if (argv.icon && !(0, fs_extra_1.pathExistsSync)(argv.icon)) {
27
- console.warn(`Cannot find icon in ${chalk_1.default.red(argv.icon)}. Switching to ${chalk_1.default.green("default")} icon.`);
28
- delete argv.icon;
29
- }
30
- return argv;
24
+ const HELP_TEXT = [
25
+ "",
26
+ "Usage: create-windowless-app [projectName] [options]",
27
+ "",
28
+ "Arguments:",
29
+ " projectName project name",
30
+ "",
31
+ "Options:",
32
+ " -v, --verbose print additional logs",
33
+ " -i, --interactive interactive mode",
34
+ " -t, --typescript use typescript (default: true)",
35
+ " --no-typescript disable typescript",
36
+ " -c, --icon <file> override default launcher icon file",
37
+ " --version Show version number",
38
+ " --help Show help",
39
+ ""
40
+ ].join("\n");
41
+ const exitWithHelp = (code, prefix) => {
42
+ const output = prefix ? `${prefix}\n${HELP_TEXT}` : HELP_TEXT;
43
+ process.stdout.write(output);
44
+ process.exit(code);
31
45
  };
32
46
  const parseCommand = (argv) => __awaiter(void 0, void 0, void 0, function* () {
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- const command = (0, yargs_1.default)((0, helpers_1.hideBin)(argv))
35
- .command("* [projectName]", "project name", (yargs) => {
36
- return yargs.positional("projectName", {
37
- describe: "project name",
38
- type: "string"
47
+ var _a;
48
+ const args = argv.slice(2);
49
+ let parsed;
50
+ try {
51
+ parsed = (0, util_1.parseArgs)({
52
+ args,
53
+ options: {
54
+ "verbose": { type: "boolean", short: "v" },
55
+ "interactive": { type: "boolean", short: "i" },
56
+ "typescript": { type: "boolean", short: "t", default: true },
57
+ "no-typescript": { type: "boolean" },
58
+ "icon": { type: "string", short: "c" },
59
+ "help": { type: "boolean" },
60
+ "version": { type: "boolean" }
61
+ },
62
+ allowPositionals: true,
63
+ strict: true
39
64
  });
40
- }, () => { })
41
- .option("verbose", {
42
- alias: "v",
43
- type: "boolean",
44
- description: "print additional logs"
45
- })
46
- .option("interactive", {
47
- type: "boolean",
48
- alias: "i",
49
- description: "interactive mode"
50
- })
51
- .option("typescript", {
52
- alias: "t",
53
- type: "boolean",
54
- description: "use typescript",
55
- default: true
56
- })
57
- .option("husky", {
58
- alias: "h",
59
- type: "boolean",
60
- description: "install husky pre-commit hook for building launcher",
61
- default: true
62
- })
63
- .option("icon", {
64
- alias: "c",
65
- type: "string",
66
- description: "override default launcher icon file"
67
- })
68
- .check(({ projectName, interactive, help }) => {
69
- if (projectName && typeof (0, validation_1.validateProjectNameInput)(projectName) === "string") {
70
- throw new Error("Invalid project name");
71
- }
72
- else if (!projectName && !interactive && !help) {
73
- throw new Error("Missing project name");
74
- }
75
- return true;
76
- })
77
- .version("version", packageJson.version)
78
- .help()
79
- .middleware(validateInput)
80
- .strict()
81
- .argv;
82
- let programConfig;
83
- if (command.interactive) {
84
- programConfig = yield (0, interactive_1.interactiveMode)();
85
65
  }
86
- else {
87
- programConfig = {
88
- projectName: command.projectName,
89
- verbose: command.verbose,
90
- typescript: command.typescript,
91
- husky: command.husky,
92
- icon: command.icon
93
- };
66
+ catch (err) {
67
+ const message = err instanceof Error ? err.message : String(err);
68
+ exitWithHelp(1, `Error: ${message}\n`);
69
+ return undefined;
70
+ }
71
+ const { values, positionals } = parsed;
72
+ if (values.help) {
73
+ exitWithHelp(0);
74
+ return undefined;
75
+ }
76
+ if (values.version) {
77
+ process.stdout.write(`${packageJson.version}\n`);
78
+ process.exit(0);
79
+ return undefined;
80
+ }
81
+ const projectName = positionals[0];
82
+ const isInteractive = !!values.interactive;
83
+ if (projectName && typeof (0, validation_1.validateProjectNameInput)(projectName) === "string") {
84
+ exitWithHelp(1, "Error: Invalid project name\n");
85
+ return undefined;
86
+ }
87
+ if (!projectName && !isInteractive) {
88
+ exitWithHelp(1, "Error: Missing project name\n");
89
+ return undefined;
90
+ }
91
+ if (isInteractive) {
92
+ return (0, interactive_1.interactiveMode)();
93
+ }
94
+ const typescript = !values["no-typescript"] && ((_a = values.typescript) !== null && _a !== void 0 ? _a : true);
95
+ let icon = values.icon;
96
+ if (icon && !(0, fs_1.existsSync)(icon)) {
97
+ console.warn(`Cannot find icon in ${chalk_1.default.red(icon)}. Switching to ${chalk_1.default.green("default")} icon.`);
98
+ icon = undefined;
94
99
  }
95
- return programConfig;
100
+ return {
101
+ projectName: projectName,
102
+ verbose: values.verbose,
103
+ typescript,
104
+ icon
105
+ };
96
106
  });
97
107
  exports.parseCommand = parseCommand;
package/dist/consts.js CHANGED
@@ -7,28 +7,18 @@ exports.consts = {
7
7
  "winston"
8
8
  ],
9
9
  devDependencies: [
10
- "fs-extra",
11
- "jest",
12
10
  "webpack",
13
11
  "webpack-cli",
14
12
  "copy-webpack-plugin",
15
13
  "rimraf",
16
- "cross-spawn",
17
14
  "postject"
18
15
  ],
19
- huskyDependencies: [
20
- "husky"
21
- ],
22
16
  tsDevDependencies: [
23
- "@types/jest",
24
17
  "@types/node",
25
- "@tsconfig/node20",
26
18
  "@types/node-notifier",
27
- "@types/winston",
28
19
  "ts-loader",
29
20
  "ts-node",
30
- "typescript",
31
- "@types/cross-spawn"
21
+ "typescript"
32
22
  ],
33
23
  errorLogFilePatterns: [
34
24
  "npm-debug.log"
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -38,7 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
48
  exports.createWindowlessApp = void 0;
39
49
  const chalk_1 = __importDefault(require("chalk"));
40
50
  const path = __importStar(require("path"));
41
- const fs_extra_1 = require("fs-extra");
51
+ const fs = __importStar(require("fs"));
42
52
  const launcherCompiler_1 = require("./launcherCompiler");
43
53
  const consts_1 = require("./consts");
44
54
  const createWindowlessAppUtils_1 = require("./createWindowlessAppUtils");
@@ -47,58 +57,51 @@ const cliParser_1 = require("./cliParser");
47
57
  const packageJson_1 = require("./packageJson");
48
58
  const dependencies_1 = require("./dependencies");
49
59
  const files_1 = require("./files");
60
+ const handleInstallError = (reason, root, appName) => {
61
+ console.log();
62
+ console.log("Aborting installation.");
63
+ if (reason.command) {
64
+ console.log(` ${chalk_1.default.cyan(reason.command)} has failed.`);
65
+ }
66
+ else {
67
+ console.log(chalk_1.default.red("Unexpected error. Please report it as a bug:"));
68
+ console.log(reason);
69
+ }
70
+ console.log();
71
+ // On 'exit' we will delete these files from target directory.
72
+ (0, createWindowlessAppUtils_1.deleteFilesInDir)(root, (file) => consts_1.consts.knownGeneratedFiles.includes(file), (file) => console.log(`Deleting generated file... ${chalk_1.default.cyan(file)}`));
73
+ const remainingFiles = fs.readdirSync(path.join(root));
74
+ if (!remainingFiles.length) {
75
+ // Delete target folder if empty
76
+ console.log(`Deleting ${chalk_1.default.cyan(`${appName}/`)} from ${chalk_1.default.cyan(path.resolve(root, ".."))}`);
77
+ process.chdir(path.resolve(root, ".."));
78
+ fs.rmSync(path.join(root), { recursive: true, force: true });
79
+ }
80
+ console.log("Done (with errors).");
81
+ process.exit(1);
82
+ };
50
83
  const run = (root, appName, originalDirectory, programConfig) => __awaiter(void 0, void 0, void 0, function* () {
51
- const { typescript, husky, icon, verbose } = programConfig;
84
+ const { typescript, icon, verbose } = programConfig;
52
85
  try {
53
- const dependenciesManager = new dependencies_1.DependenciesManager(typescript, husky);
86
+ const dependenciesManager = new dependencies_1.DependenciesManager(typescript);
54
87
  yield dependenciesManager.installAll(verbose);
55
- const fileManager = new files_1.FileManager(root, appName, typescript, husky, icon);
56
- yield fileManager.copyTemplate();
88
+ const fileManager = new files_1.FileManager({ targetRoot: root, appName, typeScript: typescript, icon });
89
+ fileManager.copyTemplate();
57
90
  // Launcher
58
- (0, fs_extra_1.ensureDirSync)(path.resolve(root, "resources", "bin"));
91
+ fs.mkdirSync(path.resolve(root, "resources", "bin"), { recursive: true });
59
92
  yield (0, launcherCompiler_1.compileLauncher)();
60
93
  console.log("Done");
61
94
  }
62
95
  catch (reason) {
63
- console.log();
64
- console.log("Aborting installation.");
65
- if (reason.command) {
66
- console.log(` ${chalk_1.default.cyan(reason.command)} has failed.`);
67
- }
68
- else {
69
- console.log(chalk_1.default.red("Unexpected error. Please report it as a bug:"));
70
- console.log(reason);
71
- }
72
- console.log();
73
- // On 'exit' we will delete these files from target directory.
74
- const knownGeneratedFiles = [...consts_1.consts.knownGeneratedFiles];
75
- const currentFiles = (0, fs_extra_1.readdirSync)(path.join(root));
76
- currentFiles.forEach((file) => {
77
- knownGeneratedFiles.forEach((fileToMatch) => {
78
- // This removes all knownGeneratedFiles.
79
- if (file === fileToMatch) {
80
- console.log(`Deleting generated file... ${chalk_1.default.cyan(file)}`);
81
- (0, fs_extra_1.removeSync)(path.join(root, file));
82
- }
83
- });
84
- });
85
- const remainingFiles = (0, fs_extra_1.readdirSync)(path.join(root));
86
- if (!remainingFiles.length) {
87
- // Delete target folder if empty
88
- console.log(`Deleting ${chalk_1.default.cyan(`${appName}/`)} from ${chalk_1.default.cyan(path.resolve(root, ".."))}`);
89
- process.chdir(path.resolve(root, ".."));
90
- (0, fs_extra_1.removeSync)(path.join(root));
91
- }
92
- console.log("Done (with errors).");
93
- process.exit(1);
96
+ handleInstallError(reason, root, appName);
94
97
  }
95
98
  });
96
99
  const createApp = (programConfig) => __awaiter(void 0, void 0, void 0, function* () {
97
- const { projectName, typescript, husky } = programConfig;
100
+ const { projectName, typescript } = programConfig;
98
101
  const root = path.resolve(projectName);
99
102
  const appName = path.basename(root);
100
103
  (0, createWindowlessAppUtils_1.checkAppName)(appName);
101
- (0, fs_extra_1.ensureDirSync)(projectName);
104
+ fs.mkdirSync(projectName, { recursive: true });
102
105
  if (!(0, createWindowlessAppUtils_1.isSafeToCreateProjectIn)(root, projectName)) {
103
106
  process.exit(1);
104
107
  }
@@ -116,9 +119,6 @@ const createApp = (programConfig) => __awaiter(void 0, void 0, void 0, function*
116
119
  if (!typescript) {
117
120
  packageJson.withJavaScript();
118
121
  }
119
- if (husky) {
120
- packageJson.withHusky();
121
- }
122
122
  (0, files_1.writeJson)(path.join(root, "package.json"), packageJson.build());
123
123
  yield run(root, appName, originalDirectory, programConfig);
124
124
  }
@@ -128,7 +128,7 @@ const createApp = (programConfig) => __awaiter(void 0, void 0, void 0, function*
128
128
  });
129
129
  const createWindowlessApp = (argv) => __awaiter(void 0, void 0, void 0, function* () {
130
130
  const programConfig = yield (0, cliParser_1.parseCommand)(argv);
131
- if (programConfig.projectName) {
131
+ if (programConfig === null || programConfig === void 0 ? void 0 : programConfig.projectName) {
132
132
  return createApp(programConfig);
133
133
  }
134
134
  });
@@ -1,14 +1,47 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.replaceAppNamePlaceholder = exports.checkAppName = exports.isSafeToCreateProjectIn = exports.PACKAGE_JSON_FILENAME = void 0;
39
+ exports.replaceAppNamePlaceholder = exports.deleteFilesInDir = exports.checkAppName = exports.isSafeToCreateProjectIn = exports.PACKAGE_JSON_FILENAME = void 0;
7
40
  const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
8
41
  const chalk_1 = __importDefault(require("chalk"));
9
42
  const path_1 = __importDefault(require("path"));
10
43
  const consts_1 = require("./consts");
11
- const fs_extra_1 = require("fs-extra");
44
+ const fs = __importStar(require("fs"));
12
45
  // These files should be allowed to remain on a failed install, but then silently removed during the next create.
13
46
  const errorLogFilePatterns = consts_1.consts.errorLogFilePatterns;
14
47
  exports.PACKAGE_JSON_FILENAME = "package.json";
@@ -19,7 +52,7 @@ exports.PACKAGE_JSON_FILENAME = "package.json";
19
52
  const isSafeToCreateProjectIn = (root, name) => {
20
53
  const validFiles = consts_1.consts.validFiles;
21
54
  console.log();
22
- const conflicts = (0, fs_extra_1.readdirSync)(root)
55
+ const conflicts = fs.readdirSync(root)
23
56
  .filter((file) => !validFiles.includes(file))
24
57
  // IntelliJ IDEA creates module files before CRA is launched
25
58
  .filter((file) => !/\.iml$/.test(file))
@@ -36,15 +69,7 @@ const isSafeToCreateProjectIn = (root, name) => {
36
69
  return false;
37
70
  }
38
71
  // Remove any remnant files from a previous installation
39
- const currentFiles = (0, fs_extra_1.readdirSync)(path_1.default.join(root));
40
- currentFiles.forEach((file) => {
41
- errorLogFilePatterns.forEach((errorLogFilePattern) => {
42
- // This will catch `npm-debug.log*` files
43
- if (file.indexOf(errorLogFilePattern) === 0) {
44
- (0, fs_extra_1.removeSync)(path_1.default.join(root, file));
45
- }
46
- });
47
- });
72
+ (0, exports.deleteFilesInDir)(root, (file) => errorLogFilePatterns.some((pattern) => file.indexOf(pattern) === 0));
48
73
  return true;
49
74
  };
50
75
  exports.isSafeToCreateProjectIn = isSafeToCreateProjectIn;
@@ -72,6 +97,15 @@ const checkAppName = (appName) => {
72
97
  }
73
98
  };
74
99
  exports.checkAppName = checkAppName;
100
+ const deleteFilesInDir = (root, shouldDelete, onDelete) => {
101
+ fs.readdirSync(root).forEach((file) => {
102
+ if (shouldDelete(file)) {
103
+ onDelete === null || onDelete === void 0 ? void 0 : onDelete(file);
104
+ fs.rmSync(path_1.default.join(root, file), { recursive: true, force: true });
105
+ }
106
+ });
107
+ };
108
+ exports.deleteFilesInDir = deleteFilesInDir;
75
109
  const replaceAppNamePlaceholder = (appName, str) => {
76
110
  return str.replace(/##APPNAME##/g, `${appName}`);
77
111
  };
@@ -26,56 +26,28 @@ var _DependenciesManager_dependencies, _DependenciesManager_devDependencies;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.DependenciesManager = void 0;
28
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
- ];
29
+ const child_process_1 = require("child_process");
30
+ const consts_1 = require("../consts");
58
31
  const install = (dependencies, isDev, verbose) => __awaiter(void 0, void 0, void 0, function* () {
59
- const command = "npm";
60
32
  const args = ["install", isDev ? "--save-dev" : "--save", "--save-exact", "--loglevel", "error"].concat(dependencies);
61
33
  if (verbose) {
62
34
  args.push("--verbose");
63
35
  }
64
36
  console.log(`Installing ${chalk_1.default.green(isDev ? "dev dependencies" : "dependencies")}.`);
65
37
  console.log();
66
- cross_spawn_1.default.sync(command, args, { stdio: "inherit" });
38
+ const spawnResult = (0, child_process_1.spawnSync)(`npm ${args.join(" ")}`, { stdio: "inherit", shell: true });
39
+ if (spawnResult.status !== 0) {
40
+ return Promise.reject({ command: `npm ${args.join(" ")}` });
41
+ }
67
42
  });
68
43
  class DependenciesManager {
69
- constructor(typescript, husky) {
44
+ constructor(typescript) {
70
45
  _DependenciesManager_dependencies.set(this, []);
71
46
  _DependenciesManager_devDependencies.set(this, []);
72
- __classPrivateFieldSet(this, _DependenciesManager_dependencies, dependencies, "f");
73
- __classPrivateFieldSet(this, _DependenciesManager_devDependencies, devDependencies, "f");
47
+ __classPrivateFieldSet(this, _DependenciesManager_dependencies, consts_1.consts.dependencies, "f");
48
+ __classPrivateFieldSet(this, _DependenciesManager_devDependencies, consts_1.consts.devDependencies, "f");
74
49
  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");
50
+ __classPrivateFieldSet(this, _DependenciesManager_devDependencies, __classPrivateFieldGet(this, _DependenciesManager_devDependencies, "f").concat(consts_1.consts.tsDevDependencies), "f");
79
51
  }
80
52
  }
81
53
  installAll(verbose) {
@@ -1,13 +1,4 @@
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
3
  if (kind === "m") throw new TypeError("Private method is not writable");
13
4
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -22,51 +13,43 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
22
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
15
  };
25
- var _FileManager_templatesRoot, _FileManager_targetRoot, _FileManager_typeScript, _FileManager_husky, _FileManager_icon, _FileManager_formatter;
16
+ var _FileManager_templatesRoot, _FileManager_targetRoot, _FileManager_typeScript, _FileManager_icon, _FileManager_formatter;
26
17
  Object.defineProperty(exports, "__esModule", { value: true });
27
18
  exports.FileManager = void 0;
28
19
  const _1 = require(".");
29
20
  const createWindowlessAppUtils_1 = require("../createWindowlessAppUtils");
30
- const fs_extra_1 = require("fs-extra");
21
+ const fs_1 = require("fs");
31
22
  const path_1 = __importDefault(require("path"));
32
23
  class FileManager {
33
- constructor(targetRoot, appName, typeScript, husky, icon) {
24
+ constructor({ targetRoot, appName, typeScript, icon }) {
34
25
  _FileManager_templatesRoot.set(this, void 0);
35
26
  _FileManager_targetRoot.set(this, void 0);
36
27
  _FileManager_typeScript.set(this, void 0);
37
- _FileManager_husky.set(this, void 0);
38
28
  _FileManager_icon.set(this, void 0);
39
29
  _FileManager_formatter.set(this, void 0);
40
30
  __classPrivateFieldSet(this, _FileManager_templatesRoot, path_1.default.resolve(__dirname, "..", "..", "templates"), "f");
41
31
  __classPrivateFieldSet(this, _FileManager_targetRoot, targetRoot, "f");
42
32
  __classPrivateFieldSet(this, _FileManager_typeScript, typeScript, "f");
43
- __classPrivateFieldSet(this, _FileManager_husky, husky, "f");
44
33
  __classPrivateFieldSet(this, _FileManager_icon, icon, "f");
45
34
  __classPrivateFieldSet(this, _FileManager_formatter, (str) => (0, createWindowlessAppUtils_1.replaceAppNamePlaceholder)(appName, str), "f");
46
35
  }
47
36
  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
- });
37
+ // common files
38
+ (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"));
39
+ // TypeScript or JavaScript
40
+ if (__classPrivateFieldGet(this, _FileManager_typeScript, "f")) {
41
+ (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"));
42
+ }
43
+ else {
44
+ (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"));
45
+ }
46
+ // Launcher
47
+ (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"));
48
+ // Icon
49
+ if (__classPrivateFieldGet(this, _FileManager_icon, "f")) {
50
+ (0, fs_1.copyFileSync)(path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_icon, "f")), path_1.default.resolve(__classPrivateFieldGet(this, _FileManager_targetRoot, "f"), "launcher", "launcher.ico"));
51
+ }
69
52
  }
70
53
  }
71
54
  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();
55
+ _FileManager_templatesRoot = new WeakMap(), _FileManager_targetRoot = new WeakMap(), _FileManager_typeScript = new WeakMap(), _FileManager_icon = new WeakMap(), _FileManager_formatter = new WeakMap();
@@ -4,45 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.copyFolderRecursiveSync = exports.writeJson = void 0;
7
- const fs_extra_1 = require("fs-extra");
7
+ const fs_1 = require("fs");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const os_1 = __importDefault(require("os"));
10
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);
11
+ (0, fs_1.writeFileSync)(fileName, JSON.stringify(json, null, 2).replace(/\n/g, os_1.default.EOL) + os_1.default.EOL);
12
12
  };
13
13
  exports.writeJson = writeJson;
14
14
  const TEXT_FORMAT_EXTENSIONS = new Set([".ts", ".js", ".cs", ".json", ".csproj"]);
15
15
  function copyFileSyncWithFormatter(sourceFile, targetFile, formatter) {
16
- console.log(`copyFileSyncWithFormatter from ${sourceFile} to ${targetFile}`);
17
- if ((0, fs_extra_1.existsSync)(targetFile)) {
16
+ if ((0, fs_1.existsSync)(targetFile)) {
18
17
  throw new Error(`Target file already exists: ${targetFile}`);
19
18
  }
20
19
  const ext = path_1.default.extname(sourceFile);
21
20
  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" });
21
+ const data = (0, fs_1.readFileSync)(sourceFile, { encoding: "utf8" });
22
+ (0, fs_1.writeFileSync)(targetFile, formatter(data), { encoding: "utf8" });
25
23
  }
26
24
  else {
27
- const data = (0, fs_extra_1.readFileSync)(sourceFile);
28
- (0, fs_extra_1.writeFileSync)(targetFile, data);
25
+ const data = (0, fs_1.readFileSync)(sourceFile);
26
+ (0, fs_1.writeFileSync)(targetFile, data);
29
27
  }
30
28
  }
31
29
  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);
30
+ if (!(0, fs_1.existsSync)(targetFolder)) {
31
+ (0, fs_1.mkdirSync)(targetFolder);
36
32
  }
37
- else if (!(0, fs_extra_1.lstatSync)(targetFolder).isDirectory()) {
33
+ else if (!(0, fs_1.lstatSync)(targetFolder).isDirectory()) {
38
34
  throw new Error("Target exists and is not a directory.");
39
35
  }
40
36
  // Copy
41
- if ((0, fs_extra_1.lstatSync)(sourceFolder).isDirectory()) {
42
- (0, fs_extra_1.readdirSync)(sourceFolder).forEach((child) => {
37
+ if ((0, fs_1.lstatSync)(sourceFolder).isDirectory()) {
38
+ (0, fs_1.readdirSync)(sourceFolder).forEach((child) => {
43
39
  const curSource = path_1.default.join(sourceFolder, child);
44
40
  const curTarget = path_1.default.join(targetFolder, child);
45
- if ((0, fs_extra_1.lstatSync)(curSource).isDirectory()) {
41
+ if ((0, fs_1.lstatSync)(curSource).isDirectory()) {
46
42
  (0, exports.copyFolderRecursiveSync)(curSource, curTarget, formatter);
47
43
  }
48
44
  else {
@@ -25,12 +25,6 @@ const interactiveMode = () => {
25
25
  name: "typescript",
26
26
  default: true
27
27
  },
28
- {
29
- type: "confirm",
30
- message: "Install Husky:",
31
- name: "husky",
32
- default: true
33
- },
34
28
  {
35
29
  type: "confirm",
36
30
  message: "Verbose:",
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,20 +41,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
42
  });
33
43
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
44
  Object.defineProperty(exports, "__esModule", { value: true });
38
45
  exports.compileLauncher = exports.checkMsbuildInPath = void 0;
39
- const fs_extra_1 = require("fs-extra");
46
+ const fs = __importStar(require("fs"));
40
47
  const path = __importStar(require("path"));
41
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
48
+ const child_process_1 = require("child_process");
42
49
  const COMPILER = "msbuild.exe";
43
50
  const checkMsbuildInPath = (exit) => __awaiter(void 0, void 0, void 0, function* () {
51
+ var _a;
44
52
  // Check for compiler in %PATH%
45
- const promises = process.env.path.split(";").map((p) => (0, fs_extra_1.pathExists)(path.resolve(p, COMPILER)));
53
+ const promises = ((_a = process.env.PATH) !== null && _a !== void 0 ? _a : "").split(";").map((p) => fs.promises.access(path.resolve(p, COMPILER)).then(() => true, () => false));
46
54
  const results = yield Promise.all(promises);
47
- const compilerFound = results.find((result) => !!result);
55
+ const compilerFound = !!results.find((result) => !!result);
48
56
  if (exit && !compilerFound) {
49
57
  console.error(`You need "${COMPILER}" in your %PATH% in order to compile the launcher executable.`);
50
58
  process.exit(1);
@@ -56,7 +64,7 @@ const checkMsbuildInPath = (exit) => __awaiter(void 0, void 0, void 0, function*
56
64
  exports.checkMsbuildInPath = checkMsbuildInPath;
57
65
  const compileLauncher = () => __awaiter(void 0, void 0, void 0, function* () {
58
66
  const args = ["./launcher/launcher.csproj"];
59
- const spawnResult = cross_spawn_1.default.sync(COMPILER, args, { stdio: "inherit" });
67
+ const spawnResult = (0, child_process_1.spawnSync)(COMPILER, args, { stdio: "inherit" });
60
68
  if (spawnResult.status !== 0) {
61
69
  return Promise.reject({ command: `${COMPILER} ${args.join(" ")}` });
62
70
  }
package/dist/nodeUtils.js CHANGED
@@ -5,18 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.checkThatNpmCanReadCwd = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
8
+ const child_process_1 = require("child_process");
9
9
  const checkThatNpmCanReadCwd = () => {
10
10
  const cwd = process.cwd();
11
- let childOutput = null;
11
+ let childOutput = "";
12
12
  try {
13
- const spawnResult = cross_spawn_1.default.sync("npm", ["config", "list"]);
13
+ const spawnResult = (0, child_process_1.spawnSync)("npm config list", { shell: true });
14
14
  if (spawnResult.status !== 0) {
15
15
  return false;
16
16
  }
17
17
  childOutput = spawnResult.output.toString();
18
18
  }
19
19
  catch (err) {
20
+ console.error(chalk_1.default.red("Failed to run `npm config list`:"), err);
20
21
  return false;
21
22
  }
22
23
  const lines = childOutput.split("\n");
@@ -24,7 +25,7 @@ const checkThatNpmCanReadCwd = () => {
24
25
  // "; cwd = C:\path\to\current\dir" (unquoted)
25
26
  // I couldn't find an easier way to get it.
26
27
  const prefix = "; cwd = ";
27
- const line = lines.find((line) => line.indexOf(prefix) === 0);
28
+ const line = lines.find((line) => line.startsWith(prefix));
28
29
  if (typeof line !== "string") {
29
30
  // Fail gracefully. They could remove it.
30
31
  return true;
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _PackageJsonBuilder_appName, _PackageJsonBuilder_typescript, _PackageJsonBuilder_husky;
13
+ var _PackageJsonBuilder_appName, _PackageJsonBuilder_typescript;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.PackageJsonBuilder = void 0;
16
16
  const packageJsonConsts_1 = require("./packageJsonConsts");
@@ -18,17 +18,12 @@ class PackageJsonBuilder {
18
18
  constructor(appName) {
19
19
  _PackageJsonBuilder_appName.set(this, void 0);
20
20
  _PackageJsonBuilder_typescript.set(this, true);
21
- _PackageJsonBuilder_husky.set(this, false);
22
21
  __classPrivateFieldSet(this, _PackageJsonBuilder_appName, appName, "f");
23
22
  }
24
23
  withJavaScript() {
25
24
  __classPrivateFieldSet(this, _PackageJsonBuilder_typescript, false, "f");
26
25
  return this;
27
26
  }
28
- withHusky() {
29
- __classPrivateFieldSet(this, _PackageJsonBuilder_husky, true, "f");
30
- return this;
31
- }
32
27
  build() {
33
28
  let packageJson = (0, packageJsonConsts_1.getPackageJsonBase)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"));
34
29
  if (__classPrivateFieldGet(this, _PackageJsonBuilder_typescript, "f")) {
@@ -37,11 +32,8 @@ class PackageJsonBuilder {
37
32
  else {
38
33
  packageJson = Object.assign(Object.assign({}, packageJson), { scripts: Object.assign(Object.assign({}, packageJson.scripts), (0, packageJsonConsts_1.getJsScripts)(__classPrivateFieldGet(this, _PackageJsonBuilder_appName, "f"))) });
39
34
  }
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
35
  return packageJson;
44
36
  }
45
37
  }
46
38
  exports.PackageJsonBuilder = PackageJsonBuilder;
47
- _PackageJsonBuilder_appName = new WeakMap(), _PackageJsonBuilder_typescript = new WeakMap(), _PackageJsonBuilder_husky = new WeakMap();
39
+ _PackageJsonBuilder_appName = new WeakMap(), _PackageJsonBuilder_typescript = new WeakMap();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHuskyScripts = exports.getJsScripts = exports.getTsScripts = exports.getPackageJsonBase = void 0;
3
+ exports.getJsScripts = exports.getTsScripts = exports.getPackageJsonBase = void 0;
4
4
  const getPackageJsonBase = (appName) => ({
5
5
  name: appName,
6
6
  version: "0.1.0",
@@ -18,12 +18,8 @@ const getSingleExecutableApplicationsScripts = (appName) => ({
18
18
  "node-sea:sign": `signtool sign /fd SHA256 dist/${appName}.exe`,
19
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
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)));
21
+ const getCommonScripts = (appName) => (Object.assign({ "prewebpack": "rimraf build && rimraf dist", "webpack": "webpack", "prebuild": "npm run check-node-version", "rebuild-launcher": "msbuild launcher/launcher.csproj" }, getSingleExecutableApplicationsScripts(appName)));
22
+ const getTsScripts = (appName) => (Object.assign({ "start": "ts-node src/index.ts", "type-check": "tsc --build tsconfig.json", "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)\"" }, getCommonScripts(appName)));
22
23
  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
+ const getJsScripts = (appName) => (Object.assign({ "start": "node src/index.js", "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)\"" }, getCommonScripts(appName)));
24
25
  exports.getJsScripts = getJsScripts;
25
- const getHuskyScripts = (appName) => ({
26
- "prepare": "git config --get core.hookspath || husky",
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;
@@ -0,0 +1 @@
1
+ {"root":["../src/checknodeversion.ts","../src/cliparser.ts","../src/consts.ts","../src/createwindowlessapp.ts","../src/createwindowlessapputils.ts","../src/index.ts","../src/interactive.ts","../src/launchercompiler.ts","../src/main.ts","../src/nodeutils.ts","../src/validation.ts","../src/dependencies/dependenciesmanager.ts","../src/dependencies/index.ts","../src/files/filemanager.ts","../src/files/fileutils.ts","../src/files/index.ts","../src/packagejson/index.ts","../src/packagejson/packagejsonbuilder.ts","../src/packagejson/packagejsonconsts.ts"],"version":"5.9.3"}
@@ -8,6 +8,15 @@ const validate_npm_package_name_1 = __importDefault(require("validate-npm-packag
8
8
  const validateProjectNameInput = (value) => {
9
9
  var _a, _b;
10
10
  const result = (0, validate_npm_package_name_1.default)(value);
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";
11
+ if (result.validForNewPackages) {
12
+ return true;
13
+ }
14
+ if ((_a = result === null || result === void 0 ? void 0 : result.errors) === null || _a === void 0 ? void 0 : _a[0]) {
15
+ return result.errors[0];
16
+ }
17
+ if ((_b = result === null || result === void 0 ? void 0 : result.warnings) === null || _b === void 0 ? void 0 : _b[0]) {
18
+ return result.warnings[0];
19
+ }
20
+ return "Invalid project name";
12
21
  };
13
22
  exports.validateProjectNameInput = validateProjectNameInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-windowless-app",
3
- "version": "11.0.3",
3
+ "version": "13.0.6",
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/ integration_test/ templates/",
18
+ "eslint": "eslint src/ test/ integration_test/ templates/ *.ts",
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",
@@ -56,54 +56,52 @@
56
56
  },
57
57
  "homepage": "https://github.com/yoavain/create-windowless-app#readme",
58
58
  "devDependencies": {
59
- "@tsconfig/node20": "20.1.4",
60
- "@types/cross-spawn": "6.0.6",
61
- "@types/fs-extra": "11.0.4",
62
- "@types/inquirer": "8.2.10",
63
- "@types/jest": "29.5.12",
59
+ "@eslint/compat": "2.0.2",
60
+ "@eslint/eslintrc": "3.3.4",
61
+ "@eslint/js": "9.39.3",
62
+ "@tsconfig/node20": "20.1.9",
63
+ "@types/jest": "30.0.0",
64
64
  "@types/mock-fs": "4.13.4",
65
- "@types/node": "20.12.8",
65
+ "@types/node": "24.10.15",
66
66
  "@types/node-notifier": "8.0.5",
67
67
  "@types/validate-npm-package-name": "4.0.2",
68
68
  "@types/winston": "2.4.4",
69
- "@typescript-eslint/eslint-plugin": "7.8.0",
70
- "@typescript-eslint/parser": "7.8.0",
69
+ "@typescript-eslint/eslint-plugin": "8.56.1",
70
+ "@typescript-eslint/parser": "8.56.1",
71
71
  "add-shebang": "0.1.0",
72
- "copy-webpack-plugin": "12.0.2",
73
- "cross-env": "7.0.3",
74
- "del": "6.1.1",
75
- "eslint": "8.57.0",
76
- "eslint-plugin-import": "2.29.1",
77
- "eslint-plugin-jest": "28.4.0",
78
- "eslint-plugin-n": "17.4.0",
79
- "eslint-plugin-security": "1.7.1",
72
+ "copy-webpack-plugin": "13.0.1",
73
+ "cross-env": "10.1.0",
74
+ "eslint": "9.39.3",
75
+ "eslint-import-resolver-typescript": "4.4.4",
76
+ "eslint-plugin-import": "2.32.0",
77
+ "eslint-plugin-jest": "29.15.0",
78
+ "eslint-plugin-n": "17.24.0",
79
+ "eslint-plugin-security": "4.0.0",
80
80
  "global-npm": "0.5.0",
81
- "husky": "9.0.11",
82
- "jest": "29.7.0",
83
- "lint-staged": "15.2.2",
84
- "mock-fs": "5.2.0",
81
+ "globals": "17.3.0",
82
+ "husky": "9.1.7",
83
+ "jest": "30.2.0",
84
+ "lint-staged": "16.2.7",
85
+ "mock-fs": "5.5.0",
85
86
  "mocked-env": "1.3.5",
86
87
  "node-notifier": "10.0.1",
87
- "nyc": "15.1.0",
88
+ "nyc": "18.0.0",
88
89
  "postject": "1.0.0-alpha.6",
89
- "prettier": "3.2.5",
90
- "rimraf": "5.0.5",
90
+ "prettier": "3.8.1",
91
+ "rimraf": "6.1.3",
91
92
  "tmp-promise": "3.0.3",
92
- "ts-jest": "29.1.2",
93
- "ts-loader": "9.5.1",
93
+ "ts-jest": "29.4.6",
94
+ "ts-loader": "9.5.4",
94
95
  "ts-node": "10.9.2",
95
- "typescript": "5.4.5",
96
- "webpack": "5.91.0",
97
- "webpack-cli": "5.1.4",
98
- "winston": "3.13.0"
96
+ "typescript": "5.9.3",
97
+ "webpack": "5.105.3",
98
+ "webpack-cli": "6.0.1",
99
+ "winston": "3.19.0"
99
100
  },
100
101
  "dependencies": {
101
102
  "chalk": "4.1.2",
102
- "cross-spawn": "7.0.3",
103
- "fs-extra": "11.2.0",
104
- "inquirer": "8.2.6",
105
- "validate-npm-package-name": "5.0.0",
106
- "yargs": "17.7.2"
103
+ "inquirer": "11.1.0",
104
+ "validate-npm-package-name": "7.0.2"
107
105
  },
108
106
  "lint-staged": {
109
107
  "*.(ts|js)": [
@@ -1,14 +1,14 @@
1
- const fs = require("fs-extra");
1
+ const fs = require("fs");
2
2
  const path = require("path");
3
- const spawn = require("cross-spawn");
3
+ const { spawnSync } = require("child_process");
4
4
 
5
5
  const COMPILER = "msbuild.exe";
6
6
 
7
- const checkCscInPath = async (exit) => {
7
+ const checkMsbuildInPath = async (exit) => {
8
8
  // Check for compiler in %PATH%
9
- const promises = process.env.path.split(";").map((p) => fs.pathExists(path.resolve(p, COMPILER)));
9
+ const promises = (process.env.PATH ?? "").split(";").map((p) => fs.promises.access(path.resolve(p, COMPILER)).then(() => true, () => false));
10
10
  const results = await Promise.all(promises);
11
- const compilerFound = await results.find((result) => !!result);
11
+ const compilerFound = !!results.find((result) => !!result);
12
12
 
13
13
  if (exit && !compilerFound) {
14
14
  console.error(`You need "${COMPILER}" in your %PATH% in order to compile the launcher executable.`);
@@ -22,10 +22,10 @@ const checkCscInPath = async (exit) => {
22
22
  const compileLauncher = async () => {
23
23
  const args = ["./launcher/launcher.csproj"];
24
24
 
25
- const spawnResult = spawn.sync(COMPILER, args, { stdio: "inherit" });
25
+ const spawnResult = spawnSync(COMPILER, args, { stdio: "inherit" });
26
26
  if (spawnResult.status !== 0) {
27
27
  return Promise.reject({ command: `${COMPILER} ${args.join(" ")}` });
28
28
  }
29
29
  };
30
30
 
31
- module.exports = { checkCscInPath, compileLauncher };
31
+ module.exports = { checkMsbuildInPath, compileLauncher };
@@ -9,6 +9,9 @@ module.exports = {
9
9
  path: path.join(__dirname, "_build"),
10
10
  filename: "index.js"
11
11
  },
12
+ resolve: {
13
+ extensions: [".js"]
14
+ },
12
15
  plugins: [
13
16
  new CopyWebpackPlugin({
14
17
  patterns: [
@@ -1,15 +1,15 @@
1
- import { pathExists } from "fs-extra";
1
+ import * as fs from "fs";
2
2
  import * as path from "path";
3
- import spawn from "cross-spawn";
3
+ import { spawnSync } from "child_process";
4
4
  import type { SpawnSyncReturns } from "child_process";
5
5
 
6
6
  const COMPILER: string = "msbuild.exe";
7
7
 
8
8
  export const checkMsbuildInPath = async (exit?: boolean): Promise<boolean> => {
9
9
  // Check for compiler in %PATH%
10
- const promises = process.env.path.split(";").map((p) => pathExists(path.resolve(p, COMPILER)));
10
+ const promises = (process.env.PATH ?? "").split(";").map((p) => fs.promises.access(path.resolve(p, COMPILER)).then(() => true, () => false));
11
11
  const results: boolean[] = await Promise.all(promises);
12
- const compilerFound: boolean = results.find((result) => !!result);
12
+ const compilerFound: boolean = !!results.find((result) => !!result);
13
13
 
14
14
  if (exit && !compilerFound) {
15
15
  console.error(`You need "${COMPILER}" in your %PATH% in order to compile the launcher executable.`);
@@ -23,7 +23,7 @@ export const checkMsbuildInPath = async (exit?: boolean): Promise<boolean> => {
23
23
  export const compileLauncher = async (): Promise<void> => {
24
24
  const args: string[] = ["./launcher/launcher.csproj"];
25
25
 
26
- const spawnResult: SpawnSyncReturns<Buffer> = spawn.sync(COMPILER, args, { stdio: "inherit" });
26
+ const spawnResult: SpawnSyncReturns<Buffer> = spawnSync(COMPILER, args, { stdio: "inherit" });
27
27
  if (spawnResult.status !== 0) {
28
28
  return Promise.reject({ command: `${COMPILER} ${args.join(" ")}` });
29
29
  }
@@ -1,10 +1,14 @@
1
1
  {
2
- "extends": "@tsconfig/node20",
3
2
  "compilerOptions": {
3
+ "lib": ["es2023"],
4
+ "module": "node16",
5
+ "moduleResolution": "node16",
6
+ "target": "es6",
4
7
  "strict": false,
5
8
  "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
6
11
  "allowJs": true,
7
- "target": "es6",
8
12
  "noEmit": true,
9
13
  "verbatimModuleSyntax": false
10
14
  },
@@ -1 +0,0 @@
1
- npm run pre-commit