@cocreate/cli 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.19.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.18.0...v1.19.0) (2023-03-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * link supports defining repos to excute and repolist to link ([a8c50dc](https://github.com/CoCreate-app/CoCreate-cli/commit/a8c50dcf810280b2cb61aa6b23748768ca90485d))
7
+
1
8
  # [1.18.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.17.2...v1.18.0) (2023-03-29)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cli",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Polyrepo management bash CLI tool. Run all git commands and yarn commands on multiple repositories. Also includes a few custom macros for cloning, installing, etc.",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,7 +1,7 @@
1
1
  const spawn = require('../spawn');
2
2
  const colors = require('colors');
3
3
 
4
- module.exports = async function linkPackages(repos) {
4
+ module.exports = async function linkPackages(repos, repoList) {
5
5
  const failed = [], isLinked = {};
6
6
 
7
7
  try {
@@ -11,8 +11,10 @@ module.exports = async function linkPackages(repos) {
11
11
  continue
12
12
 
13
13
  console.log(repo.packageName, 'configuring ...')
14
- await doLink(repo.deps, repo, repos, failed, isLinked)
15
- await doLink(repo.devDeps, repo, repos, failed, isLinked)
14
+ if (!repoList)
15
+ repoList = repos
16
+ await doLink(repo.deps, repo, repoList, failed, isLinked)
17
+ await doLink(repo.devDeps, repo, repoList, failed, isLinked)
16
18
  }
17
19
  }
18
20
  catch (err) {
@@ -2,9 +2,10 @@ const fs = require('fs')
2
2
  const path = require("path")
3
3
  const util = require('node:util');
4
4
  const exec = util.promisify(require('node:child_process').exec);
5
+ const spawn = require('../spawn');
5
6
 
6
7
  const cwdPath = path.resolve(process.cwd());
7
- const cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
8
+ let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
8
9
 
9
10
 
10
11
  // let doInstall = process.argv[2];
@@ -15,10 +16,13 @@ module.exports = async function symlink(repos) {
15
16
  reposLength = repos.length
16
17
 
17
18
  for (let i = 0; i < repos.length; i++) {
18
- if (repos[i].install == true) {
19
+
20
+ if (cwdPath === repos[i].absolutePath && !fs.existsSync(cwdNodeModulesPath)) {
21
+ await install(repos[i], repos)
19
22
  reposLength -= 1
20
- await install(repos[i])
21
-
23
+ } else if (repos[i].install == true) {
24
+ reposLength -= 1
25
+ await install(repos[i], repos)
22
26
  } else if (cwdPath !== repos[i].absolutePath) {
23
27
  await createSymlink(repos[i])
24
28
  }
@@ -77,35 +81,45 @@ function erSymlink(name, dest){
77
81
  }
78
82
 
79
83
 
80
- async function install(repo) {
84
+ async function install(repo, repos) {
81
85
  let dpath = repo.absolutePath
82
86
  if (!fs.existsSync(dpath)) {
83
87
  failed.push({name: 'install', des: 'path doesn\'t exist:' + dpath})
84
88
  return console.error(dpath, 'not exist')
85
89
  }
86
90
  try {
87
- // let node_modules = path.resolve(dpath, 'node_modules');
88
- // if (fs.existsSync(node_modules)) {
89
- // fs.rm(node_modules, { recursive: true, force: true }, function (err) {
90
- // if (err) {
91
- // console.log('failed');
92
- // } else {
93
- // erSymlink(repo.name, dest)
94
- // }
95
- // });
96
- // }
97
- let {error} = await exec(`${repo.packageManager} install `, { cwd: dpath })
98
- if (!error) {
99
- console.log(repo.name, 'installed')
100
- let linkFailed = await require('./link.js')([repo])
91
+ let exitCode = await spawn(repo.packageManager, ['install'], {
92
+ cwd: repo.absolutePath,
93
+ shell: true,
94
+ stdio: 'inherit'
95
+ });
96
+
97
+ if (exitCode !== 0) {
98
+ failed.push({
99
+ name: repo.name,
100
+ des: `${repo.packageManager} install failed`
101
+ })
102
+ console.error(`${repo.name}: ${repo.packageManager} install failed`.red)
103
+ } else {
104
+ // ToDo: needs to run on defined repo but stiil require all repos in order to xecute on correct path
105
+ let linkFailed = await require('./link.js')([repo], repos)
101
106
  if (linkFailed)
102
107
  failed.push(linkFailed)
103
-
104
- } else {
105
- failed.push({name: 'install ', des: error})
106
- console.error(repo.name, 'failed to install', error)
108
+
107
109
  }
108
110
 
111
+ // let {error} = await exec(`${repo.packageManager} install `, { cwd: dpath })
112
+ // if (!error) {
113
+ // console.log(repo.name, 'installed')
114
+ // let linkFailed = await require('./link.js')([repo])
115
+ // if (linkFailed)
116
+ // failed.push(linkFailed)
117
+
118
+ // } else {
119
+ // failed.push({name: 'install ', des: error})
120
+ // console.error(repo.name, 'failed to install', error)
121
+ // }
122
+
109
123
  }
110
124
  catch (err) {
111
125
  console.error(repo.name, 'did not install', err)