@cocreate/cli 1.22.0 → 1.24.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,18 @@
1
+ # [1.24.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.23.0...v1.24.0) (2023-04-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * default server is removed and replaced with main server, deleteServer removes from enabled and available ([5fed172](https://github.com/CoCreate-app/CoCreate-cli/commit/5fed172e7f2d48b413ef5a74d9ddfaf9313db066))
7
+
8
+ # [1.23.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.22.0...v1.23.0) (2023-04-23)
9
+
10
+
11
+ ### Features
12
+
13
+ * repos not required, args is an array ([7329430](https://github.com/CoCreate-app/CoCreate-cli/commit/7329430ff526291ae1ca99f647000d5581b80734))
14
+ * repos not required, args updated to an array ([43c8197](https://github.com/CoCreate-app/CoCreate-cli/commit/43c8197d2e5d07a34842ca17b7a1bef625171daf))
15
+
1
16
  # [1.22.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.21.0...v1.22.0) (2023-04-23)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cli",
3
- "version": "1.22.0",
3
+ "version": "1.24.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",
package/src/coc.js CHANGED
@@ -57,14 +57,16 @@ if (config['c'] && fs.existsSync(config['c'])) {
57
57
  }];
58
58
  directory = path.dirname(packageJsonPath);
59
59
  console.warn(`using ${packageJsonPath} configuration`.yellow);
60
- } else {
61
- console.error(`a configuration file can not be found`.red);
62
- process.exit(1);
63
- }
60
+ }
61
+ // else {
62
+ // console.error(`a configuration file can not be found`.red);
63
+ // process.exit(1);
64
+ // }
64
65
  config = { hideMessage: false, ...config };
65
66
 
66
67
  (async () => {
67
- repos = await addMeta(repos, [], directory)
68
+ if (repos && repos.length)
69
+ repos = await addMeta(repos, [], directory)
68
70
  let failed = await execute(command, repos, config);
69
71
  if (failed) {
70
72
  if (failed.length === 0)
@@ -1,4 +1,4 @@
1
- const {createServer, deleteServer} = require('./other/nodeCertManager.js')
1
+ const {createServer, deleteServer} = require('./other/nginxConfigManager.js')
2
2
 
3
3
  module.exports = async function nginx(repos, args) {
4
4
  let failed = [];
@@ -66,8 +66,6 @@ server {
66
66
  listen 443 ssl http2;
67
67
  ssl_certificate /etc/letsencrypt/live/${host}/fullchain.pem;
68
68
  ssl_certificate_key /etc/letsencrypt/live/${host}/privkey.pem;
69
- include /etc/letsencrypt/options-ssl-nginx.conf;
70
- ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
71
69
 
72
70
  }
73
71
 
@@ -80,13 +78,45 @@ server {
80
78
  let test = await exec(`sudo nginx -t`);
81
79
  if (test.stderr.includes('test is successful')) {
82
80
  await exec(`sudo systemctl reload nginx`);
83
- console.log('test passed reloading nginx', host)
81
+ console.log(host, 'test passed reloading nginx')
84
82
  response[host] = true
85
83
  } else {
86
- console.log('test failed', host)
84
+ console.log(host, 'test failed')
87
85
  response[host] = false
88
86
  }
89
87
  }
88
+
89
+
90
+ if (!fs.existsSync(`${enabled}main`)) {
91
+ let main = `server {
92
+ listen 80 default_server;
93
+ listen [::]:80 default_server;
94
+
95
+
96
+ server_name _;
97
+ return 301 https://$host$request_uri;
98
+ }`
99
+
100
+ fs.writeFileSync(`${available}main`, main)
101
+ await exec(`sudo ln -s ${available}main ${enabled}`);
102
+
103
+ if (fs.existsSync(`${enabled}default`))
104
+ fs.unlinkSync(`${enabled}default`)
105
+ if (fs.existsSync(`${available}default`))
106
+ fs.unlinkSync(`${available}default`)
107
+
108
+ let test = await exec(`sudo nginx -t`);
109
+ if (test.stderr.includes('test is successful')) {
110
+ await exec(`sudo systemctl reload nginx`);
111
+ console.log('main test passed reloading nginx')
112
+ response['main'] = true
113
+ } else {
114
+ console.log('main test failed')
115
+ response['main'] = false
116
+ }
117
+
118
+ }
119
+
90
120
  return response
91
121
  }
92
122
 
@@ -95,13 +125,14 @@ async function deleteServer(hosts) {
95
125
  if (!Array.isArray(hosts))
96
126
  hosts = [hosts]
97
127
  for (let host of hosts) {
98
- fs.unlinkSync(`${available}${host}`)
128
+ if (fs.existsSync(`${enabled}${host}`))
129
+ fs.unlinkSync(`${enabled}${host}`)
130
+ if (fs.existsSync(`${available}${host}`))
131
+ fs.unlinkSync(`${available}${host}`)
132
+
99
133
  response[host] = true
100
134
  }
101
135
  return response
102
136
  }
103
137
 
104
- // createServer(['cocreate.app'])
105
- // deleteServer(['cocreate.app'])
106
-
107
138
  module.exports = {createServer, deleteServer}
package/src/execute.js CHANGED
@@ -6,10 +6,11 @@ const util = require('node:util');
6
6
  const exec = util.promisify(require('node:child_process').exec);
7
7
 
8
8
 
9
- module.exports = async function execute(command, repos, config) {
9
+ module.exports = async function execute(command, repos = [], config) {
10
10
  let failed = [];
11
- let type = command.split(' ')[0]
12
- let args = command.replace(type, '').replaceAll("'", '"').trim()
11
+ let args = command.replaceAll("'", '"').trim().split(' ')
12
+ let type = args[0]
13
+ args.shift()
13
14
 
14
15
  let predefined = path.resolve(__dirname, 'commands', type + '.js');
15
16
 
@@ -18,16 +19,13 @@ module.exports = async function execute(command, repos, config) {
18
19
 
19
20
  if (repos.length == 1)
20
21
  console.log(`running on ${repos[0].name} repo`.blue)
21
- else
22
+ else if (repos.length)
22
23
  console.log('running on all repos'.blue)
23
24
 
24
- failed = require(predefined)(args, repos)
25
+ failed = require(predefined)(repos, args)
25
26
 
26
27
  } else {
27
-
28
- // let type = command.split(' ')[0]
29
- // let args = command.replace(type, '').replaceAll("'", '"').trim()
30
-
28
+
31
29
  for (let repo of repos) {
32
30
  try {
33
31
  if (repo.exclude && repo.exclude.includes(type))
@@ -42,7 +40,7 @@ module.exports = async function execute(command, repos, config) {
42
40
  if (error)
43
41
  exitCode = 1
44
42
  } else {
45
- exitCode = await spawn(type, [`${args}`], {
43
+ exitCode = await spawn(type, args, {
46
44
  cwd: repo.absolutePath,
47
45
  shell: true,
48
46
  stdio: 'inherit'