@common-stack/generate-plugin 6.0.6-alpha.53 → 6.0.6-alpha.58

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.0.6-alpha.58](https://github.com/cdmbase/common-stack/compare/v6.0.6-alpha.57...v6.0.6-alpha.58) (2024-10-15)
7
+
8
+ **Note:** Version bump only for package @common-stack/generate-plugin
9
+
6
10
  ## [6.0.6-alpha.53](https://github.com/cdmbase/common-stack/compare/v6.0.6-alpha.52...v6.0.6-alpha.53) (2024-10-13)
7
11
 
8
12
  **Note:** Version bump only for package @common-stack/generate-plugin
package/README.md CHANGED
@@ -78,7 +78,7 @@ CREATE sample-stack/tools/runLint.mjs
78
78
  CREATE sample-stack/tools/sortPackageJson.mjs
79
79
  CREATE sample-stack/tools/update-dependencies.mjs
80
80
  CREATE sample-stack/tools/update-dependency-link.mjs
81
- CREATE sample-stack/tools/update-dependency-version.js
81
+ CREATE sample-stack/tools/update-dependency-version.mjs
82
82
  CREATE sample-stack/tools/updateUtils.mjs
83
83
  CREATE sample-stack/tools/webpack/server.config.js
84
84
  CREATE sample-stack/tools/webpack-util.js
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "@apollo/client": "^3.9.0",
64
64
  "@babel/runtime": "^7.20.1",
65
- "@common-stack/server-stack": "link:../../../../../common-server-stack",
65
+ "@common-stack/server-stack": "6.0.6-alpha.53",
66
66
  "@container-stack/mailing-api-server": "^5.2.1-alpha.2",
67
67
  "@container-stack/territory": "^5.2.1-alpha.2",
68
68
  "@remix-run/node": "~2.10.1",
@@ -52,7 +52,7 @@
52
52
  "watch:test": "cross-env ENV_FILE=../../config/test/test.env node ./server.js"
53
53
  },
54
54
  "dependencies": {
55
- "@common-stack/frontend-stack-react": "link:../../../../../frontend-stack-react",
55
+ "@common-stack/frontend-stack-react": "6.0.6-alpha.53",
56
56
  "@react-icons/all-files": "^4.1.0",
57
57
  "classnames": "^2.2.6",
58
58
  "compression": "^1.7.4",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@cdmbase/vite-plugin-i18next-loader": "^2.0.12",
83
- "@common-stack/rollup-vite-utils": "link:../../../../../rollup-vite-utils",
83
+ "@common-stack/rollup-vite-utils": "6.0.6-alpha.57",
84
84
  "@remix-run/dev": "~2.10.1",
85
85
  "@remix-run/serve": "~2.10.1",
86
86
  "cross-env": "^7.0.3",
@@ -43,7 +43,7 @@
43
43
  "db:migrate": "knex migrate:latest --cwd . --knexfile ./servers/backend-server/knexfile.js",
44
44
  "db:migrate:rollback": "knex migrate:rollback --cwd . --knexfile ./servers/backend-server/knexfile.js",
45
45
  "db:seed": "yarn db:migrate && knex seed:run --cwd . --knexfile ./servers/backend-server/knexfile.js",
46
- "predevpublish": "if ! git show-ref --verify --quiet refs/remotes/origin/$PUBLISH_BRANCH; then git checkout -b $PUBLISH_BRANCH && git push -u origin $PUBLISH_BRANCH; fi && git fetch origin $PUBLISH_BRANCH && git checkout $PUBLISH_BRANCH && git pull origin $PUBLISH_BRANCH && git merge -s recursive -X theirs $REPOSITORY_BRANCH -m \"merge from $REPOSITORY_BRANCH\" && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit",
46
+ "predevpublish": "if ! git show-ref --verify --quiet refs/remotes/origin/$PUBLISH_BRANCH; then git checkout -b $PUBLISH_BRANCH && git push -u origin $PUBLISH_BRANCH; fi && git fetch origin $PUBLISH_BRANCH && git checkout $PUBLISH_BRANCH && git pull origin $PUBLISH_BRANCH && git merge -s recursive -X theirs $REPOSITORY_BRANCH -m \"merge from $REPOSITORY_BRANCH\" && yarn gitcommit && node tools/update-dependency-version.mjs && yarn gitcommit",
47
47
  "devpublish": "lerna publish prerelease --ignore-scripts --exact",
48
48
  "postdevpublish": "git checkout $REPOSITORY_BRANCH",
49
49
  "devpublish:auto": "yarn devpublish -- --yes",
@@ -60,7 +60,7 @@
60
60
  "husky-skip": "cross-env HUSKY_SKIP_HOOKS=1",
61
61
  "jest": "./node_modules/.bin/jest",
62
62
  "lerna": "lerna bootstrap",
63
- "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit",
63
+ "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.mjs && yarn gitcommit",
64
64
  "lernapublish": "lerna publish patch --ignore-scripts",
65
65
  "postlernapublish": "yarn update-lerna-on-develop && git checkout master",
66
66
  "lint": "eslint --ext js --ext ts --ext tsx --ext md",
@@ -146,8 +146,8 @@
146
146
  "@babel/preset-typescript": "^7.18.6",
147
147
  "@babel/register": "^7.18.9",
148
148
  "@babel/runtime": "^7.20.1",
149
- "@common-stack/env-list-loader": "link:../../../../../env-list-loader",
150
- "@common-stack/generate-plugin": "link:../../../..",
149
+ "@common-stack/env-list-loader": "6.0.6-alpha.50",
150
+ "@common-stack/generate-plugin": "6.0.6-alpha.53",
151
151
  "@emotion/babel-plugin": "^11.11.0",
152
152
  "@graphql-codegen/add": "^5.0.2",
153
153
  "@graphql-codegen/cli": "^5.0.2",
@@ -1,4 +1,4 @@
1
- import glob from 'glob';
1
+ import { glob } from 'glob';
2
2
  import { resolve, dirname, relative } from 'path';
3
3
  import { readFileSync, writeFileSync } from 'fs';
4
4
  import simpleGit from 'simple-git';
@@ -8,25 +8,27 @@ import { fileURLToPath } from 'url';
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = dirname(__filename);
10
10
 
11
+ const git = simpleGit();
12
+ const monorepoRoot = resolve(__dirname, '..');
13
+
11
14
  // matching prettier format
12
15
  const JSON_SPACING = 4;
13
16
  const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
14
17
 
15
- const git = simpleGit();
16
-
17
- const monorepoRoot = resolve(__dirname, '..');
18
-
19
- const findPackageJsonFiles = () => {
20
- return new Promise((resolve, reject) => {
21
- glob(
18
+ const findPackageJsonFiles = async () => {
19
+ try {
20
+ const findings = await glob(
22
21
  `${monorepoRoot}/+(servers|portable-devices|packages|packages-modules)/**/package.json`,
23
22
  { onlyFiles: true, ignore: '**/node_modules/**' },
24
23
  (err, files) => {
25
- if (err) reject(`Unable to scan directory: ${err}`);
24
+ if (err) reject();
26
25
  resolve(files);
27
26
  },
28
27
  );
29
- });
28
+ return findings;
29
+ } catch (err) {
30
+ throw new Error(`Unable to scan directory: ${err}`);
31
+ }
30
32
  };
31
33
 
32
34
  const buildPackageMap = async () => {
@@ -1,26 +1,34 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
- const simpleGit = require('simple-git');
4
- const glob = require('glob');
1
+ import { glob } from 'glob';
2
+ import { resolve, join, dirname, relative } from 'path';
3
+ import { readFileSync, writeFileSync } from 'fs';
4
+ import simpleGit from 'simple-git';
5
+ import { runLintStaged } from './runLint.mjs';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
5
10
 
6
11
  const git = simpleGit();
7
- const monorepoRoot = path.resolve(__dirname, '..');
12
+ const monorepoRoot = resolve(__dirname, '..');
8
13
 
9
14
  // matching prettier format
10
15
  const JSON_SPACING = 4;
11
16
  const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
12
17
 
13
- const findPackageJsonFiles = () => {
14
- return new Promise((resolve, reject) => {
15
- glob(
18
+ const findPackageJsonFiles = async () => {
19
+ try {
20
+ const findings = await glob(
16
21
  `${monorepoRoot}/+(servers|portable-devices|packages|packages-modules)/**/package.json`,
17
22
  { onlyFiles: true, ignore: '**/node_modules/**' },
18
23
  (err, files) => {
19
- if (err) reject(`Unable to scan directory: ${err}`);
24
+ if (err) reject();
20
25
  resolve(files);
21
26
  },
22
27
  );
23
- });
28
+ return findings;
29
+ } catch (err) {
30
+ throw new Error(`Unable to scan directory: ${err}`);
31
+ }
24
32
  };
25
33
 
26
34
  const buildPackageMap = async () => {
@@ -28,10 +36,10 @@ const buildPackageMap = async () => {
28
36
  const packageMap = new Map();
29
37
 
30
38
  packageJsonFiles.forEach((file) => {
31
- const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
39
+ const packageJson = JSON.parse(readFileSync(file, 'utf8'));
32
40
  if (packageJson.name) {
33
41
  packageMap.set(packageJson.name, {
34
- path: path.dirname(file),
42
+ path: dirname(file),
35
43
  version: packageJson.version,
36
44
  });
37
45
  }
@@ -46,11 +54,11 @@ const searchAndUpdate = (dependencies, filePath, obj, packageMap) => {
46
54
  for (const key in dependencies) {
47
55
  if (dependencies[key].startsWith('link:')) {
48
56
  const relativeDepFolder = dependencies[key].split('link:')[1];
49
- const dependencyFolder = path.join(path.dirname(filePath), relativeDepFolder);
57
+ const dependencyFolder = join(dirname(filePath), relativeDepFolder);
50
58
 
51
59
  try {
52
- const packageJsonPath = path.join(dependencyFolder, 'package.json');
53
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
60
+ const packageJsonPath = join(dependencyFolder, 'package.json');
61
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
54
62
  if (dependencies[key] !== packageJson.version) {
55
63
  dependencies[key] = packageJson.version;
56
64
  modified = true;
@@ -74,7 +82,7 @@ const searchAndUpdate = (dependencies, filePath, obj, packageMap) => {
74
82
  if (ADD_END_NEWLINE) {
75
83
  formattedJson += '\n';
76
84
  }
77
- fs.writeFileSync(filePath, formattedJson, 'utf8');
85
+ writeFileSync(filePath, formattedJson, 'utf8');
78
86
  }
79
87
 
80
88
  return modified;
@@ -88,7 +96,7 @@ const updateDependencies = async () => {
88
96
  packageJsonFiles.forEach((file) => {
89
97
  if (!file.includes('node_modules')) {
90
98
  try {
91
- const data = fs.readFileSync(file, 'utf8');
99
+ const data = readFileSync(file, 'utf8');
92
100
  const obj = JSON.parse(data);
93
101
  const { dependencies, peerDependencies, devDependencies } = obj;
94
102
 
@@ -106,16 +114,39 @@ const updateDependencies = async () => {
106
114
  }
107
115
  });
108
116
 
109
- if (modifiedFiles.length > 0) {
110
- await git.add(modifiedFiles);
111
- await git.commit('Updated packages to use correct versions and linked dependencies');
112
- } else {
113
- console.log('No changes detected');
114
- }
117
+ return modifiedFiles;
115
118
  };
116
119
 
117
120
  updateDependencies()
118
- .then(() => {
119
- console.log('Dependencies updated successfully.');
121
+ .then((modifiedFiles) => {
122
+ const addArray = modifiedFiles.map((file) => `./${relative(monorepoRoot, file)}`);
123
+ console.log('-- Modified Files --', modifiedFiles, addArray);
124
+ if (addArray.length === 0) {
125
+ console.log('No files to stage.');
126
+ return null;
127
+ }
128
+ return git.add(addArray).then(() => git.status()); // Stage files and then check status
120
129
  })
121
- .catch((err) => console.error(`Error in updateDependencies: ${err.message}`));
130
+ .then((status) => {
131
+ if (status && status.modified.length) {
132
+ const fileArray = status.modified.filter((element) => element.includes('package.json'));
133
+ const addArray = fileArray.map((element) => `./${element}`);
134
+ return git
135
+ .add(addArray)
136
+ .then(runLintStaged)
137
+ .then(() => git.status()); // Run lint-staged after adding
138
+ } else {
139
+ console.log('No changes to lint or commit.');
140
+ return null;
141
+ }
142
+ })
143
+ .then((status) => {
144
+ if (status && status.modified.length > 0) {
145
+ return git.commit('Updated packages to use correct versions');
146
+ } else {
147
+ console.log('No changes after linting. Nothing to commit.');
148
+ }
149
+ })
150
+ .catch((err) => {
151
+ console.error(err);
152
+ });
@@ -25,11 +25,11 @@
25
25
  "watch": "npm run start:dev"
26
26
  },
27
27
  "dependencies": {
28
- "@common-stack/client-core": "link:../../../../../common-client-core",
29
- "@common-stack/core": "link:../../../../../common-core",
30
- "@common-stack/server-core": "link:../../../../../common-server-core",
31
- "@common-stack/server-stack": "link:../../../../../common-server-stack",
32
- "@common-stack/store-mongo": "link:../../../../../common-store-mongo",
28
+ "@common-stack/client-core": "6.0.6-alpha.53",
29
+ "@common-stack/core": "6.0.6-alpha.50",
30
+ "@common-stack/server-core": "6.0.6-alpha.50",
31
+ "@common-stack/server-stack": "6.0.6-alpha.53",
32
+ "@common-stack/store-mongo": "6.0.6-alpha.50",
33
33
  "@container-stack/mailing-api": "5.2.1-alpha.1",
34
34
  "helmet": "^3.21.2",
35
35
  "react": "18.2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/generate-plugin",
3
- "version": "6.0.6-alpha.53",
3
+ "version": "6.0.6-alpha.58",
4
4
  "type": "module",
5
5
  "main": "./lib/index.mjs",
6
6
  "typings": "./lib/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "watch": "yarn build:lib:watch"
18
18
  },
19
19
  "dependencies": {
20
- "@common-stack/rollup-vite-utils": "link:../../packags/rollup-vite-utils",
20
+ "@common-stack/rollup-vite-utils": "6.0.6-alpha.57",
21
21
  "tslib": "^2.3.0"
22
22
  },
23
23
  "publishConfig": {
@@ -25,5 +25,5 @@
25
25
  },
26
26
  "executors": "./executors.json",
27
27
  "generators": "./generators.json",
28
- "gitHead": "6733e4668c966b9f9a607f7f2d3774e7942ef800"
28
+ "gitHead": "14e414617883209533985a494da7db7352ec4f91"
29
29
  }
@@ -43,7 +43,7 @@
43
43
  "db:migrate": "knex migrate:latest --cwd . --knexfile ./servers/backend-server/knexfile.js",
44
44
  "db:migrate:rollback": "knex migrate:rollback --cwd . --knexfile ./servers/backend-server/knexfile.js",
45
45
  "db:seed": "yarn db:migrate && knex seed:run --cwd . --knexfile ./servers/backend-server/knexfile.js",
46
- "predevpublish": "if ! git show-ref --verify --quiet refs/remotes/origin/$PUBLISH_BRANCH; then git checkout -b $PUBLISH_BRANCH && git push -u origin $PUBLISH_BRANCH; fi && git fetch origin $PUBLISH_BRANCH && git checkout $PUBLISH_BRANCH && git pull origin $PUBLISH_BRANCH && git merge -s recursive -X theirs $REPOSITORY_BRANCH -m \"merge from $REPOSITORY_BRANCH\" && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit",
46
+ "predevpublish": "if ! git show-ref --verify --quiet refs/remotes/origin/$PUBLISH_BRANCH; then git checkout -b $PUBLISH_BRANCH && git push -u origin $PUBLISH_BRANCH; fi && git fetch origin $PUBLISH_BRANCH && git checkout $PUBLISH_BRANCH && git pull origin $PUBLISH_BRANCH && git merge -s recursive -X theirs $REPOSITORY_BRANCH -m \"merge from $REPOSITORY_BRANCH\" && yarn gitcommit && node tools/update-dependency-version.mjs && yarn gitcommit",
47
47
  "devpublish": "lerna publish prerelease --ignore-scripts --exact",
48
48
  "postdevpublish": "git checkout $REPOSITORY_BRANCH",
49
49
  "devpublish:auto": "yarn devpublish -- --yes",
@@ -60,7 +60,7 @@
60
60
  "husky-skip": "cross-env HUSKY_SKIP_HOOKS=1",
61
61
  "jest": "./node_modules/.bin/jest",
62
62
  "lerna": "lerna bootstrap",
63
- "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit",
63
+ "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.mjs && yarn gitcommit",
64
64
  "lernapublish": "lerna publish patch --ignore-scripts",
65
65
  "postlernapublish": "yarn update-lerna-on-develop && git checkout master",
66
66
  "lint": "eslint --ext js --ext ts --ext tsx --ext md",
@@ -146,8 +146,8 @@
146
146
  "@babel/preset-typescript": "^7.18.6",
147
147
  "@babel/register": "^7.18.9",
148
148
  "@babel/runtime": "^7.20.1",
149
- "@common-stack/env-list-loader": "6.0.6-alpha.5",
150
- "@common-stack/generate-plugin": "6.0.6-alpha.48",
149
+ "@common-stack/env-list-loader": "6.0.6-alpha.50",
150
+ "@common-stack/generate-plugin": "6.0.6-alpha.53",
151
151
  "@emotion/babel-plugin": "^11.11.0",
152
152
  "@graphql-codegen/add": "^5.0.2",
153
153
  "@graphql-codegen/cli": "^5.0.2",
@@ -1,4 +1,4 @@
1
- import glob from 'glob';
1
+ import { glob } from 'glob';
2
2
  import { resolve, dirname, relative } from 'path';
3
3
  import { readFileSync, writeFileSync } from 'fs';
4
4
  import simpleGit from 'simple-git';
@@ -8,25 +8,27 @@ import { fileURLToPath } from 'url';
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = dirname(__filename);
10
10
 
11
+ const git = simpleGit();
12
+ const monorepoRoot = resolve(__dirname, '..');
13
+
11
14
  // matching prettier format
12
15
  const JSON_SPACING = 4;
13
16
  const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
14
17
 
15
- const git = simpleGit();
16
-
17
- const monorepoRoot = resolve(__dirname, '..');
18
-
19
- const findPackageJsonFiles = () => {
20
- return new Promise((resolve, reject) => {
21
- glob(
18
+ const findPackageJsonFiles = async () => {
19
+ try {
20
+ const findings = await glob(
22
21
  `${monorepoRoot}/+(servers|portable-devices|packages|packages-modules)/**/package.json`,
23
22
  { onlyFiles: true, ignore: '**/node_modules/**' },
24
23
  (err, files) => {
25
- if (err) reject(`Unable to scan directory: ${err}`);
24
+ if (err) reject();
26
25
  resolve(files);
27
26
  },
28
27
  );
29
- });
28
+ return findings;
29
+ } catch (err) {
30
+ throw new Error(`Unable to scan directory: ${err}`);
31
+ }
30
32
  };
31
33
 
32
34
  const buildPackageMap = async () => {
@@ -1,26 +1,34 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
- const simpleGit = require('simple-git');
4
- const glob = require('glob');
1
+ import { glob } from 'glob';
2
+ import { resolve, join, dirname, relative } from 'path';
3
+ import { readFileSync, writeFileSync } from 'fs';
4
+ import simpleGit from 'simple-git';
5
+ import { runLintStaged } from './runLint.mjs';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
5
10
 
6
11
  const git = simpleGit();
7
- const monorepoRoot = path.resolve(__dirname, '..');
12
+ const monorepoRoot = resolve(__dirname, '..');
8
13
 
9
14
  // matching prettier format
10
15
  const JSON_SPACING = 4;
11
16
  const ADD_END_NEWLINE = true; // Set to true to add a newline at the end of the file
12
17
 
13
- const findPackageJsonFiles = () => {
14
- return new Promise((resolve, reject) => {
15
- glob(
18
+ const findPackageJsonFiles = async () => {
19
+ try {
20
+ const findings = await glob(
16
21
  `${monorepoRoot}/+(servers|portable-devices|packages|packages-modules)/**/package.json`,
17
22
  { onlyFiles: true, ignore: '**/node_modules/**' },
18
23
  (err, files) => {
19
- if (err) reject(`Unable to scan directory: ${err}`);
24
+ if (err) reject();
20
25
  resolve(files);
21
26
  },
22
27
  );
23
- });
28
+ return findings;
29
+ } catch (err) {
30
+ throw new Error(`Unable to scan directory: ${err}`);
31
+ }
24
32
  };
25
33
 
26
34
  const buildPackageMap = async () => {
@@ -28,10 +36,10 @@ const buildPackageMap = async () => {
28
36
  const packageMap = new Map();
29
37
 
30
38
  packageJsonFiles.forEach((file) => {
31
- const packageJson = JSON.parse(fs.readFileSync(file, 'utf8'));
39
+ const packageJson = JSON.parse(readFileSync(file, 'utf8'));
32
40
  if (packageJson.name) {
33
41
  packageMap.set(packageJson.name, {
34
- path: path.dirname(file),
42
+ path: dirname(file),
35
43
  version: packageJson.version,
36
44
  });
37
45
  }
@@ -46,11 +54,11 @@ const searchAndUpdate = (dependencies, filePath, obj, packageMap) => {
46
54
  for (const key in dependencies) {
47
55
  if (dependencies[key].startsWith('link:')) {
48
56
  const relativeDepFolder = dependencies[key].split('link:')[1];
49
- const dependencyFolder = path.join(path.dirname(filePath), relativeDepFolder);
57
+ const dependencyFolder = join(dirname(filePath), relativeDepFolder);
50
58
 
51
59
  try {
52
- const packageJsonPath = path.join(dependencyFolder, 'package.json');
53
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
60
+ const packageJsonPath = join(dependencyFolder, 'package.json');
61
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
54
62
  if (dependencies[key] !== packageJson.version) {
55
63
  dependencies[key] = packageJson.version;
56
64
  modified = true;
@@ -74,7 +82,7 @@ const searchAndUpdate = (dependencies, filePath, obj, packageMap) => {
74
82
  if (ADD_END_NEWLINE) {
75
83
  formattedJson += '\n';
76
84
  }
77
- fs.writeFileSync(filePath, formattedJson, 'utf8');
85
+ writeFileSync(filePath, formattedJson, 'utf8');
78
86
  }
79
87
 
80
88
  return modified;
@@ -88,7 +96,7 @@ const updateDependencies = async () => {
88
96
  packageJsonFiles.forEach((file) => {
89
97
  if (!file.includes('node_modules')) {
90
98
  try {
91
- const data = fs.readFileSync(file, 'utf8');
99
+ const data = readFileSync(file, 'utf8');
92
100
  const obj = JSON.parse(data);
93
101
  const { dependencies, peerDependencies, devDependencies } = obj;
94
102
 
@@ -106,16 +114,39 @@ const updateDependencies = async () => {
106
114
  }
107
115
  });
108
116
 
109
- if (modifiedFiles.length > 0) {
110
- await git.add(modifiedFiles);
111
- await git.commit('Updated packages to use correct versions and linked dependencies');
112
- } else {
113
- console.log('No changes detected');
114
- }
117
+ return modifiedFiles;
115
118
  };
116
119
 
117
120
  updateDependencies()
118
- .then(() => {
119
- console.log('Dependencies updated successfully.');
121
+ .then((modifiedFiles) => {
122
+ const addArray = modifiedFiles.map((file) => `./${relative(monorepoRoot, file)}`);
123
+ console.log('-- Modified Files --', modifiedFiles, addArray);
124
+ if (addArray.length === 0) {
125
+ console.log('No files to stage.');
126
+ return null;
127
+ }
128
+ return git.add(addArray).then(() => git.status()); // Stage files and then check status
120
129
  })
121
- .catch((err) => console.error(`Error in updateDependencies: ${err.message}`));
130
+ .then((status) => {
131
+ if (status && status.modified.length) {
132
+ const fileArray = status.modified.filter((element) => element.includes('package.json'));
133
+ const addArray = fileArray.map((element) => `./${element}`);
134
+ return git
135
+ .add(addArray)
136
+ .then(runLintStaged)
137
+ .then(() => git.status()); // Run lint-staged after adding
138
+ } else {
139
+ console.log('No changes to lint or commit.');
140
+ return null;
141
+ }
142
+ })
143
+ .then((status) => {
144
+ if (status && status.modified.length > 0) {
145
+ return git.commit('Updated packages to use correct versions');
146
+ } else {
147
+ console.log('No changes after linting. Nothing to commit.');
148
+ }
149
+ })
150
+ .catch((err) => {
151
+ console.error(err);
152
+ });
@@ -25,11 +25,11 @@
25
25
  "watch": "npm run start:dev"
26
26
  },
27
27
  "dependencies": {
28
- "@common-stack/client-core": "6.0.6-alpha.5",
29
- "@common-stack/core": "6.0.6-alpha.5",
30
- "@common-stack/server-core": "6.0.6-alpha.5",
31
- "@common-stack/server-stack": "6.0.6-alpha.44",
32
- "@common-stack/store-mongo": "6.0.6-alpha.34",
28
+ "@common-stack/client-core": "6.0.6-alpha.53",
29
+ "@common-stack/core": "6.0.6-alpha.50",
30
+ "@common-stack/server-core": "6.0.6-alpha.50",
31
+ "@common-stack/server-stack": "6.0.6-alpha.53",
32
+ "@common-stack/store-mongo": "6.0.6-alpha.50",
33
33
  "@container-stack/mailing-api": "5.2.1-alpha.1",
34
34
  "helmet": "^3.21.2",
35
35
  "react": "18.2.0",