@cocreate/cli 1.16.0 → 1.16.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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.16.1](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.16.0...v1.16.1) (2023-03-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * replaced ppath with absolutePath ([4bf6e35](https://github.com/CoCreate-app/CoCreate-cli/commit/4bf6e35895f08d085f27d7159e95e2a62aa420e0))
7
+ * replaced ppath with absolutePath ([b563d48](https://github.com/CoCreate-app/CoCreate-cli/commit/b563d48867d52e28467a6839d6991aeba2c4406d))
8
+
1
9
  # [1.16.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.15.0...v1.16.0) (2023-02-21)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cli",
3
- "version": "1.16.0",
3
+ "version": "1.16.1",
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",
package/src/addMeta.js CHANGED
@@ -10,7 +10,6 @@ module.exports = async function addMeta(repos, failed, directory) {
10
10
  repos[i].plainName = repos[i].name.substr(9);
11
11
 
12
12
  if (directory) {
13
- repos[i].ppath = path.resolve(directory, repos[i].path);
14
13
  repos[i].absolutePath = path.resolve(directory, repos[i].path);
15
14
  repos[i].directory = directory;
16
15
  }
@@ -10,10 +10,10 @@ let list = require('../repositories.js');
10
10
  let metaYarnLink = list.map(meta => {
11
11
  let name = path.basename(meta.path).toLowerCase();
12
12
  try {
13
- let ppath = path.resolve(meta.path);
13
+ let absolutePath = path.resolve(meta.path);
14
14
 
15
15
 
16
- let packagejson = path.resolve(ppath, 'package.json');
16
+ let packagejson = path.resolve(absolutePath, 'package.json');
17
17
  if (!fs.existsSync(packagejson)) {
18
18
  console.error('package json not found for', name);
19
19
  return false;
@@ -23,7 +23,7 @@ let metaYarnLink = list.map(meta => {
23
23
  let packageName = name.startsWith('cocreate-') ?
24
24
  '@cocreate/' + name.substr(9) : packageObj.name;
25
25
 
26
- return { ...meta, name, packageName, ppath, packageObj }
26
+ return { ...meta, name, packageName, absolutePath, packageObj }
27
27
  }
28
28
  catch (err) {
29
29
  console.error('error: ', name, err.message);
@@ -43,7 +43,7 @@ let metaYarnLink = list.map(meta => {
43
43
  function update(param) {
44
44
  // component name
45
45
  if (!param) return;
46
- let { packageObj, ppath } = param;
46
+ let { packageObj, absolutePath } = param;
47
47
  let { name, description } = packageObj;
48
48
  let shortName = name.substr(10);
49
49
  let fileContent = `# CoCreate-${shortName}
@@ -127,7 +127,7 @@ We appreciate your continued support, thank you!
127
127
 
128
128
  `;
129
129
 
130
- let MdPath = path.resolve(ppath, 'README.md')
130
+ let MdPath = path.resolve(absolutePath, 'README.md')
131
131
  let formated = prettier.format(fileContent, { semi: false, parser: "markdown" });
132
132
  if (fs.existsSync(MdPath))
133
133
  fs.unlinkSync(MdPath)
@@ -10,10 +10,10 @@ let list = require('../repositories.js');
10
10
  let metaYarnLink = list.map(meta => {
11
11
  let name = path.basename(meta.path).toLowerCase();
12
12
  try {
13
- let ppath = path.resolve(meta.path);
13
+ let absolutePath = path.resolve(meta.path);
14
14
 
15
15
 
16
- let packagejson = path.resolve(ppath, 'package.json');
16
+ let packagejson = path.resolve(absolutePath, 'package.json');
17
17
  if (!fs.existsSync(packagejson)) {
18
18
  console.error('package json not found for', name);
19
19
  return false;
@@ -23,7 +23,7 @@ let metaYarnLink = list.map(meta => {
23
23
  let packageName = name.startsWith('cocreate-') ?
24
24
  '@cocreate/' + name.substr(9) : packageObj.name;
25
25
 
26
- return { ...meta, name, packageName, ppath, packageObj }
26
+ return { ...meta, name, packageName, absolutePath, packageObj }
27
27
  }
28
28
  catch (err) {
29
29
  console.error('error: ', name, err.message);
@@ -35,7 +35,6 @@ let metaYarnLink = list.map(meta => {
35
35
  (async() => {
36
36
  for (let meta of metaYarnLink) {
37
37
  await update(meta)
38
- // await updateYarnLink(metaYarnLink[0])
39
38
  }
40
39
  })();
41
40
 
@@ -43,7 +42,7 @@ let metaYarnLink = list.map(meta => {
43
42
  function update(param) {
44
43
  // component name
45
44
  if (!param) return;
46
- let { packageObj, ppath } = param;
45
+ let { packageObj, absolutePath } = param;
47
46
  let { name, description } = packageObj;
48
47
  let shortName = name.substr(10);
49
48
  let fileContent = `# CoCreate-${shortName}
@@ -127,7 +126,7 @@ We appreciate your continued support, thank you!
127
126
 
128
127
  `;
129
128
 
130
- let MdPath = path.resolve(ppath, 'README.md')
129
+ let MdPath = path.resolve(absolutePath, 'README.md')
131
130
  let formated = prettier.format(fileContent, { semi: false, parser: "markdown" });
132
131
  if (fs.existsSync(MdPath))
133
132
  fs.unlinkSync(MdPath)
@@ -28,23 +28,24 @@ async function doLink(deps, repo, repos, failed, isLinked) {
28
28
  for (let dep of deps) {
29
29
  let depMeta = repos.find(meta => meta.packageName === dep);
30
30
  try {
31
- if (!depMeta) {
32
- // ToDo: search file system for a package.json containing the package.name
33
- failed.push({
34
- name: repo.name,
35
- des: `"${dep}" component can not be found in repositories.js`
36
- })
37
- console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
38
- continue;
39
- }
31
+ // if (!depMeta) {
32
+ // // ToDo: search file system for a package.json containing the package.name
40
33
 
34
+ // failed.push({
35
+ // name: repo.name,
36
+ // des: `"${dep}" component can not be found in repositories.js`
37
+ // })
38
+ // console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
39
+ // continue;
40
+ // }
41
41
 
42
42
 
43
- if (!isLinked[depMeta.packageName]) {
43
+
44
+ if (depMeta && !isLinked[depMeta.packageName]) {
44
45
 
45
46
  isLinked[depMeta.packageName] = true;
46
47
  let exitCode = await spawn(packageManager, ['link'], {
47
- cwd: depMeta.ppath,
48
+ cwd: depMeta.absolutePath,
48
49
  shell: true,
49
50
  stdio: 'inherit'
50
51
  });
@@ -57,10 +58,13 @@ async function doLink(deps, repo, repos, failed, isLinked) {
57
58
  console.error(`${depMeta.name}: ${packageManager} link failed`.red)
58
59
  }
59
60
  }
61
+
62
+ if (!depMeta)
63
+ depMeta = {packageName: dep}
60
64
  console.log(repo.packageName, 'linking', depMeta.packageName, '...')
61
65
 
62
66
  let exitCode = await spawn(packageManager, ['link', depMeta.packageName], {
63
- cwd: repo.ppath,
67
+ cwd: repo.absolutePath,
64
68
  shell: true,
65
69
  stdio: 'inherit'
66
70
  })
@@ -41,7 +41,7 @@ async function reAdd(deps, repo, failed, param = '') {
41
41
  console.log(`${repo.name}: `.green, `yarn ${packageListLog}`);
42
42
  // let exitCode = await spawn(`yarn`, ['add', ...param && [param], packageList], {
43
43
  let exitCode = await spawn( 'yarn', packageList, {
44
- cwd: repo.ppath, stdio: 'inherit',
44
+ cwd: repo.absolutePath, stdio: 'inherit',
45
45
  });
46
46
  if (exitCode !== 0) {
47
47
  failed.push({
package/src/execute.js CHANGED
@@ -30,14 +30,14 @@ module.exports = async function execute(command, repos, config) {
30
30
  let exitCode;
31
31
  if (config.hideMessage) {
32
32
  const { error } = await exec(command, {
33
- cwd: repo.ppath,
33
+ cwd: repo.absolutePath,
34
34
  });
35
35
 
36
36
  if (error)
37
37
  exitCode = 1
38
38
  } else
39
39
  exitCode = await spawn(command, null, {
40
- cwd: repo.ppath,
40
+ cwd: repo.absolutePath,
41
41
  shell: true,
42
42
  stdio: 'inherit'
43
43
  })
@@ -1,116 +0,0 @@
1
- // install nodejs 14 from: https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
2
- // install yarn from https://classic.yarnpkg.com/en/docs/install/#debian-stable
3
- // -> alternatives -> debian/ununtu -> run the 3 commands there consecutively
4
-
5
- // both node and nodejs --version should be the same and > then v12
6
- const fs = require('fs')
7
- const path = require("path")
8
- const { promisify } = require('util');
9
- const exec = promisify(require('child_process').exec)
10
- let list = require('../repositories.js');
11
-
12
- let pathList = list.map(o => o.path);
13
- let nameList = pathList.map(fn => path.basename(fn).toLowerCase());
14
-
15
- let CoCreateJsPath = path.resolve('../CoCreate-components/CoCreate-crdt');
16
- // console.log(syarnInstall);
17
- // process.exit()
18
-
19
- const ignore = [
20
- 'CoCreateJS',
21
- 'CoCreate-repositories',
22
- 'CoCreate-charts',
23
- 'CoCreate-codemirror',
24
- 'CoCreate-crdt',
25
- 'CoCreate-croppie',
26
- 'CoCreate-docs',
27
- 'CoCreate-domain',
28
- 'CoCreate-facebook',
29
- 'CoCreate-fullcalendar',
30
- 'CoCreate-google-auth',
31
- 'CoCreate-instagram',
32
- 'CoCreate-lighthouse',
33
- 'CoCreate-linkedin',
34
- 'CoCreate-monaco',
35
- 'CoCreate-pinterest',
36
- 'CoCreate-pickr',
37
- 'CoCreate-progress-bar',
38
- 'CoCreate-quill',
39
- 'CoCreate-s3',
40
- 'CoCreate-sengrid',
41
- 'CoCreate-shipengine',
42
- 'CoCreate-stripe',
43
- 'CoCreate-twilio',
44
- 'CoCreate-twitter',
45
- 'CoCreate-uppy',
46
- ];
47
-
48
-
49
- let doInstall = process.argv[2];
50
-
51
-
52
-
53
-
54
- (async() => {
55
- for (let i = 0; i < ignore.length; i++) {
56
- ignore[i] = ignore[i].toLowerCase();
57
- }
58
- for (let [index, name] of nameList.entries()) {
59
- if (ignore.includes(name.toLowerCase()))
60
- {
61
- if (doInstall == "true")
62
- await updateYarnInstall(pathList[index], name)
63
- }
64
- else
65
- await updateSymbolic(pathList[index], name)
66
-
67
- }
68
- })()
69
-
70
-
71
-
72
- async function updateSymbolic(dpath, name) {
73
- // let packageName = path.basename(dpath);
74
- let res1, res2;
75
- dpath = path.resolve(dpath);
76
- if (!fs.existsSync(dpath))
77
- return console.error(dpath, 'not exist')
78
-
79
- try {
80
- let dest = path.resolve(dpath, 'node_modules');
81
- if (fs.existsSync(dest))
82
- fs.rmdirSync(dest, { recursive: true })
83
- console.log('copying node_modules to', name);
84
- res2 = await exec(`ln -sf ${CoCreateJsPath}/node_modules ${dest} `, { cwd: CoCreateJsPath })
85
-
86
- console.log(name, 'is finished')
87
- }
88
- catch (err) {
89
- console.error(name, 'had error for command', err.cmd, 'with response:', res1, res2, err)
90
- }
91
-
92
- }
93
-
94
-
95
-
96
- async function updateYarnInstall(dpath, name) {
97
- // let packageName = path.basename(dpath);
98
- let res1, res2;
99
- dpath = path.resolve(dpath);
100
- if (!fs.existsSync(dpath))
101
- return console.error(dpath, 'not exist')
102
-
103
- try {
104
- let node_modules = path.resolve(dpath, 'node_modules');
105
- if (fs.existsSync(node_modules))
106
- fs.rmdirSync(node_modules,{ recursive: true })
107
- console.log('yarn install inside', name);
108
- res2 = await exec(`yarn install `, { cwd: dpath })
109
-
110
- console.log(name, 'is finished', '\n')
111
- }
112
- catch (err) {
113
- console.error(name, 'had error for command', err.cmd, 'with response:', res1, res2, err)
114
- }
115
-
116
- }
@@ -1,107 +0,0 @@
1
- const fs = require('fs')
2
- const path = require("path")
3
- const {
4
- promisify
5
- } = require('util');
6
- const spawn = require('../../spawn');
7
- const colors = require('colors');
8
- const addMeta = require('../../addMeta');
9
-
10
-
11
-
12
-
13
-
14
- module.exports = async function updateYarnInstall(repos, allrepo) {
15
-
16
- const failed = [],
17
- isLinked = {};
18
- try {
19
- repos = addMeta(repos, failed)
20
- allrepo = addMeta(allrepo, failed)
21
-
22
- }
23
- catch (err) {
24
- failed.push({
25
- name: 'GENERAL',
26
- des: err.message
27
- })
28
- console.log(err)
29
- }
30
-
31
- try {
32
- // console.log(repos)
33
-
34
- for (let repo of repos) {
35
-
36
- if (!repo)
37
- continue;
38
-
39
-
40
- let {
41
- ppath,
42
- packageName,
43
- deps,
44
- devDeps,
45
- name
46
- } = repo;
47
-
48
- console.log(packageName, 'configuring ...')
49
- await doLink(deps, repo, allrepo, failed, isLinked)
50
- await doLink(devDeps, repo, allrepo, failed, isLinked)
51
- }
52
- }
53
- catch (err) {
54
- failed.push({ name: 'GENERAL', des: err.message })
55
- console.error(err.red)
56
- }
57
-
58
- return failed;
59
- }
60
-
61
-
62
- async function doLink(deps, repo, allrepo, failed, isLinked) {
63
- for (let dep of deps) {
64
- let depMeta = allrepo.find(meta => meta.packageName === dep);
65
- // console.log(depMeta)
66
- // return failed;
67
- try {
68
- if (!depMeta) {
69
- failed.push({
70
- name: repo.name,
71
- des: `"${dep}" component can not be found in repositories.js`
72
- })
73
- console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
74
- continue;
75
- }
76
-
77
-
78
- let exitCode;
79
- if (depMeta.packageName === '@cocreate/crdt') {
80
-
81
- console.log('creating symbolic link')
82
- let linkPath = path.resolve(repo.ppath, 'node_modules/@cocreate', depMeta.plainName)
83
- if (fs.existsSync(linkPath))
84
- fs.unlinkSync(linkPath)
85
- exitCode = await spawn('ln', ['-s', '-f', depMeta.ppath, linkPath], {
86
- cwd: repo.ppath,
87
- stdio: 'inherit',
88
- })
89
- if (exitCode !== 0) {
90
- failed.push({
91
- name: repo.name,
92
- des: `ln failed`
93
- });
94
- console.error(`${repo.name}:ln failed`.red)
95
- }
96
-
97
- }
98
-
99
-
100
- }
101
- catch (err) {
102
- failed.push({ name: repo.packageName, des: err.message })
103
- console.error(err)
104
- }
105
-
106
- }
107
- }
@@ -1,54 +0,0 @@
1
- const fs = require('fs');
2
- const path = require("path");
3
- const spawn = require('../../spawn');
4
- const colors = require('colors');
5
- const addMeta = require('../../addMeta');
6
-
7
-
8
- module.exports = async function updateYarnLink(repos) {
9
- let failed = [];
10
-
11
- try {
12
- repos = addMeta(repos, failed);
13
-
14
- }
15
- catch (err) {
16
- failed.push({
17
- name: 'GENERAL',
18
- des: err.message
19
- });
20
-
21
- }
22
-
23
- for (let repo of repos) {
24
- await yarnInstall(repo, failed, '');
25
- }
26
- return failed;
27
-
28
- };
29
-
30
-
31
- async function yarnInstall(repo, failed, param = '') {
32
- try {
33
- console.log(`${repo.name}: `.green, `yarn install`);
34
- let exitCode = await spawn( 'yarn', ['install'], {
35
- cwd: repo.ppath, stdio: 'inherit',
36
- });
37
- if (exitCode !== 0) {
38
- failed.push({
39
- name: repo.name,
40
- des: `yarn ${param}`
41
- })
42
- console.error(`${repo.name}: yarn ${param}`.red)
43
- }
44
- }
45
- catch (err) {
46
- failed.push({
47
- name: repo.name,
48
- des: err.message
49
- })
50
- console.error(`${repo.name}: ${err.message}`.red)
51
- }
52
- }
53
-
54
-