@goldstack/nodemonx 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # NodemonX
2
-
3
- This is an enhanced version of [nodemon](https://www.npmjs.com/package/nodemon) specifically designed to support watching for code changes in projects with multiple packages/workspaces.
4
-
5
- NodemonX is used for watching for changes in [Goldstack Projects](https://goldstack.party).
1
+ # NodemonX
2
+
3
+ This is an enhanced version of [nodemon](https://www.npmjs.com/package/nodemon) specifically designed to support watching for code changes in projects with multiple packages/workspaces.
4
+
5
+ NodemonX is used for watching for changes in [Goldstack Projects](https://goldstack.party).
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env node
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- require('./../dist/src/utilsNodemonx.js')
5
- .run(process.argv)
6
- .catch((e) => {
7
- console.log(e);
8
- process.exit(1);
9
- });
1
+ #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
4
+ require('./../dist/src/utilsNodemonx.js')
5
+ .run(process.argv)
6
+ .catch((e) => {
7
+ console.log(e);
8
+ process.exit(1);
9
+ });
@@ -1,3 +1,3 @@
1
- export declare const getNearestPackageJson: (name: string) => string;
2
- export declare const run: (args: string[]) => Promise<void>;
1
+ export declare const getNearestPackageJson: (name: string) => string;
2
+ export declare const run: (args: string[]) => Promise<void>;
3
3
  //# sourceMappingURL=utilsNodemonx.d.ts.map
@@ -1,97 +1,97 @@
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.run = exports.getNearestPackageJson = void 0;
7
- const assert_1 = __importDefault(require("assert"));
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const node_watch_1 = __importDefault(require("node-watch"));
11
- const utils_sh_1 = require("@goldstack/utils-sh");
12
- const minimatch_1 = __importDefault(require("minimatch"));
13
- const utils_log_1 = require("@goldstack/utils-log");
14
- const getNearestPackageJson = (name) => {
15
- if (fs_1.default.existsSync(name + '/package.json')) {
16
- return name + '/package.json';
17
- }
18
- const baseName = path_1.default.basename(name);
19
- if (baseName === 'package.json') {
20
- return name;
21
- }
22
- const dir = path_1.default.dirname(name);
23
- if (fs_1.default.existsSync(dir + '/package.json')) {
24
- return dir + '/package.json';
25
- }
26
- if (dir === path_1.default.parse(name).root) {
27
- throw new Error('Cannot find package json in parent directories.');
28
- }
29
- // check parent directory
30
- return (0, exports.getNearestPackageJson)(path_1.default.dirname(dir));
31
- };
32
- exports.getNearestPackageJson = getNearestPackageJson;
33
- const getNearestPackageFolder = (name) => {
34
- const nearestPackageJson = (0, exports.getNearestPackageJson)(name);
35
- return path_1.default.dirname(nearestPackageJson);
36
- };
37
- const run = async (args) => {
38
- (0, assert_1.default)(args[2] === '--watch');
39
- const folder = args[3];
40
- (0, assert_1.default)(args[4] === '--exec');
41
- const [, , , , , ...commandArgs] = args;
42
- let command = commandArgs.join(' ');
43
- // removing quotation marks if present
44
- // eslint-disable-next-line quotes
45
- if (command.charAt(0) === "'" || command.charAt(0) === '"') {
46
- command = command.substr(1, command.length - 2);
47
- }
48
- const watchDir = path_1.default.resolve(folder);
49
- console.log(`Start watching ${watchDir} for running command: ${command}`);
50
- let failedPackages = [];
51
- if (!fs_1.default.existsSync('./.nodemonx.json')) {
52
- throw new Error('No .nodemonx.json file present');
53
- }
54
- const config = JSON.parse((0, utils_sh_1.read)('./.nodemonx.json'));
55
- (0, node_watch_1.default)(watchDir, { recursive: true }, function (evt, name) {
56
- // check if in file whitelist
57
- if (!config.include.find((glob) => (0, minimatch_1.default)(name, glob))) {
58
- (0, utils_log_1.debug)('Ignoring changed file since it is not in whitelist: ' + name);
59
- return;
60
- }
61
- // check if in file blacklist
62
- if (config.exclude.find((glob) => (0, minimatch_1.default)(name, glob))) {
63
- (0, utils_log_1.debug)('Ignoring changed file since it is in blacklist: ' + name);
64
- return;
65
- }
66
- console.log(`Change detected: ${name}`);
67
- const packageDir = getNearestPackageFolder(name);
68
- console.log(`Running command in: ${packageDir} ...`);
69
- (0, utils_sh_1.cd)(packageDir);
70
- failedPackages = failedPackages.filter((pkg) => pkg !== packageDir);
71
- try {
72
- (0, utils_sh_1.exec)(command, { silent: false });
73
- console.log(`✔️ Command successfully run in ${packageDir}`);
74
- }
75
- catch {
76
- console.log(`❌ ERROR building: ${packageDir}. Package will be rebuilt on next change.`);
77
- failedPackages.push(packageDir);
78
- }
79
- const failedPackagesToTest = failedPackages.filter((pkg) => pkg !== packageDir);
80
- if (failedPackagesToTest.length > 0) {
81
- console.log(`Running command for ${failedPackagesToTest.length} previously failed packages.`);
82
- for (const failedPackage of failedPackagesToTest) {
83
- (0, utils_sh_1.cd)(failedPackage);
84
- try {
85
- (0, utils_sh_1.exec)(command, { silent: false });
86
- failedPackages = failedPackages.filter((pkg) => pkg !== failedPackage);
87
- console.log(`✔️ Command successfully run for previously failed package: ${failedPackage}`);
88
- }
89
- catch {
90
- console.log(`❌ Command still failing for ${failedPackage}`);
91
- }
92
- }
93
- }
94
- });
95
- };
96
- exports.run = run;
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.run = exports.getNearestPackageJson = void 0;
7
+ const assert_1 = __importDefault(require("assert"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const node_watch_1 = __importDefault(require("node-watch"));
11
+ const utils_sh_1 = require("@goldstack/utils-sh");
12
+ const minimatch_1 = __importDefault(require("minimatch"));
13
+ const utils_log_1 = require("@goldstack/utils-log");
14
+ const getNearestPackageJson = (name) => {
15
+ if (fs_1.default.existsSync(name + '/package.json')) {
16
+ return name + '/package.json';
17
+ }
18
+ const baseName = path_1.default.basename(name);
19
+ if (baseName === 'package.json') {
20
+ return name;
21
+ }
22
+ const dir = path_1.default.dirname(name);
23
+ if (fs_1.default.existsSync(dir + '/package.json')) {
24
+ return dir + '/package.json';
25
+ }
26
+ if (dir === path_1.default.parse(name).root) {
27
+ throw new Error('Cannot find package json in parent directories.');
28
+ }
29
+ // check parent directory
30
+ return (0, exports.getNearestPackageJson)(path_1.default.dirname(dir));
31
+ };
32
+ exports.getNearestPackageJson = getNearestPackageJson;
33
+ const getNearestPackageFolder = (name) => {
34
+ const nearestPackageJson = (0, exports.getNearestPackageJson)(name);
35
+ return path_1.default.dirname(nearestPackageJson);
36
+ };
37
+ const run = async (args) => {
38
+ (0, assert_1.default)(args[2] === '--watch');
39
+ const folder = args[3];
40
+ (0, assert_1.default)(args[4] === '--exec');
41
+ const [, , , , , ...commandArgs] = args;
42
+ let command = commandArgs.join(' ');
43
+ // removing quotation marks if present
44
+ // eslint-disable-next-line quotes
45
+ if (command.charAt(0) === "'" || command.charAt(0) === '"') {
46
+ command = command.substr(1, command.length - 2);
47
+ }
48
+ const watchDir = path_1.default.resolve(folder);
49
+ console.log(`Start watching ${watchDir} for running command: ${command}`);
50
+ let failedPackages = [];
51
+ if (!fs_1.default.existsSync('./.nodemonx.json')) {
52
+ throw new Error('No .nodemonx.json file present');
53
+ }
54
+ const config = JSON.parse((0, utils_sh_1.read)('./.nodemonx.json'));
55
+ (0, node_watch_1.default)(watchDir, { recursive: true }, function (evt, name) {
56
+ // check if in file whitelist
57
+ if (!config.include.find((glob) => (0, minimatch_1.default)(name, glob))) {
58
+ (0, utils_log_1.debug)('Ignoring changed file since it is not in whitelist: ' + name);
59
+ return;
60
+ }
61
+ // check if in file blacklist
62
+ if (config.exclude.find((glob) => (0, minimatch_1.default)(name, glob))) {
63
+ (0, utils_log_1.debug)('Ignoring changed file since it is in blacklist: ' + name);
64
+ return;
65
+ }
66
+ console.log(`Change detected: ${name}`);
67
+ const packageDir = getNearestPackageFolder(name);
68
+ console.log(`Running command in: ${packageDir} ...`);
69
+ (0, utils_sh_1.cd)(packageDir);
70
+ failedPackages = failedPackages.filter((pkg) => pkg !== packageDir);
71
+ try {
72
+ (0, utils_sh_1.exec)(command, { silent: false });
73
+ console.log(`✔️ Command successfully run in ${packageDir}`);
74
+ }
75
+ catch {
76
+ console.log(`❌ ERROR building: ${packageDir}. Package will be rebuilt on next change.`);
77
+ failedPackages.push(packageDir);
78
+ }
79
+ const failedPackagesToTest = failedPackages.filter((pkg) => pkg !== packageDir);
80
+ if (failedPackagesToTest.length > 0) {
81
+ console.log(`Running command for ${failedPackagesToTest.length} previously failed packages.`);
82
+ for (const failedPackage of failedPackagesToTest) {
83
+ (0, utils_sh_1.cd)(failedPackage);
84
+ try {
85
+ (0, utils_sh_1.exec)(command, { silent: false });
86
+ failedPackages = failedPackages.filter((pkg) => pkg !== failedPackage);
87
+ console.log(`✔️ Command successfully run for previously failed package: ${failedPackage}`);
88
+ }
89
+ catch {
90
+ console.log(`❌ Command still failing for ${failedPackage}`);
91
+ }
92
+ }
93
+ }
94
+ });
95
+ };
96
+ exports.run = run;
97
97
  //# sourceMappingURL=utilsNodemonx.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/nodemonx",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Enhanced utility for watching for changes in directories",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -39,13 +39,13 @@
39
39
  "version:apply:force": "yarn version $@ && yarn version apply"
40
40
  },
41
41
  "dependencies": {
42
- "@goldstack/utils-log": "0.3.0",
43
- "@goldstack/utils-sh": "0.5.0",
42
+ "@goldstack/utils-log": "0.3.1",
43
+ "@goldstack/utils-sh": "0.5.1",
44
44
  "minimatch": "^3.0.4",
45
45
  "node-watch": "^0.6.4"
46
46
  },
47
47
  "devDependencies": {
48
- "@goldstack/utils-git": "0.2.0",
48
+ "@goldstack/utils-git": "0.2.1",
49
49
  "@types/jest": "^28.1.8",
50
50
  "@types/minimatch": "^3.0.3",
51
51
  "@types/node": "^18.7.13",