@open-norantec/herbal 1.0.0 → 1.0.1-alpha.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.
@@ -0,0 +1,59 @@
1
+ const _ = require('lodash');
2
+ const path = require('path');
3
+ const spawn = require('child_process').spawn;
4
+ const statSync = require('node:fs').statSync;
5
+ const StringUtil = require('@open-norantec/utilities').StringUtil;
6
+ const Command = require('commander').Command;
7
+
8
+ const command = new Command();
9
+
10
+ command.action(async () => {
11
+ const findParentProjectPath = (currentPath) => {
12
+ let result = currentPath;
13
+ let hasNodeModules = false;
14
+
15
+ while (!hasNodeModules) {
16
+ const newResult = path.resolve(result, '..');
17
+ if (newResult === result) break;
18
+ result = newResult;
19
+ hasNodeModules = _.attempt(() => statSync(path.join(result, 'node_modules')).isDirectory()) === true;
20
+ }
21
+
22
+ return hasNodeModules ? result : undefined;
23
+ };
24
+
25
+ let cwd = findParentProjectPath(__dirname);
26
+
27
+ console.log('Process cwd:', process.cwd());
28
+
29
+ if (StringUtil.isFalsyString(cwd)) {
30
+ console.log('Warning: not a Node.js project path, nothing to patch, exitting...');
31
+ process.exit(0);
32
+ }
33
+
34
+ while (true) {
35
+ console.log(`Patching: ${cwd}`);
36
+
37
+ await new Promise((resolve) => {
38
+ const childProcess = spawn(
39
+ 'npx',
40
+ ['patch-package', `--patch-dir=${path.relative(process.cwd(), path.resolve(__dirname, '../patches'))}`],
41
+ {
42
+ stdio: 'inherit',
43
+ cwd,
44
+ },
45
+ );
46
+ childProcess.on('exit', () => {
47
+ resolve(undefined);
48
+ });
49
+ });
50
+
51
+ const newCwd = findParentProjectPath(cwd);
52
+
53
+ if (StringUtil.isFalsyString(newCwd)) break;
54
+
55
+ cwd = newCwd;
56
+ }
57
+ });
58
+
59
+ command.parse(process.argv);
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@open-norantec/herbal",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-alpha.1",
4
4
  "description": "Herbal is a builder and toolchain for Nest.js applications",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "rimraf dist && tsc -b"
8
+ "build": "rimraf dist && tsc -b",
9
+ "postinstall": "node ./bin/herbal-patch.js"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
@@ -16,6 +17,7 @@
16
17
  "url": "https://github.com/norantec/herbal/issues"
17
18
  },
18
19
  "files": [
20
+ "bin",
19
21
  "dist",
20
22
  "patches",
21
23
  "preserved"
@@ -30,8 +32,7 @@
30
32
  "homepage": "https://github.com/norantec/herbal#readme",
31
33
  "peerDependencies": {
32
34
  "express": ">=4.0.0 <5.0.0",
33
- "typescript": ">=5.1.0 <5.2.0",
34
- "sequelize": "6.37.7"
35
+ "typescript": ">=5.1.0 <5.2.0"
35
36
  },
36
37
  "dependencies": {
37
38
  "@nestjs/common": "^10.0.0",
@@ -43,8 +44,10 @@
43
44
  "lodash": "^4.17.21",
44
45
  "nest-winston": "^1.10.2",
45
46
  "nj-request-scope": "^1.0.10",
47
+ "patch-package": "^8.0.1",
46
48
  "reflect-metadata": "^0.2.2",
47
49
  "rxjs": "^7.8.2",
50
+ "sequelize": "6.37.7",
48
51
  "sequelize-typescript": "^2.1.5",
49
52
  "ts-patch": "^3.3.0",
50
53
  "type-fest": "^4.41.0",
@@ -65,7 +68,6 @@
65
68
  "express": "^4.21.2",
66
69
  "prettier": "^3.0.0",
67
70
  "rimraf": "^6.0.1",
68
- "sequelize": "6.37.7",
69
71
  "ts-node": "^10.0.0",
70
72
  "typescript": "~5.1.3"
71
73
  }