@cocreate/cli 1.29.2 → 1.30.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.
@@ -50,6 +50,10 @@ jobs:
50
50
  uses: actions/setup-node@v3
51
51
  with:
52
52
  node-version: 16
53
-
54
53
  - name: update documentation
55
54
  uses: CoCreate-app/CoCreate-docs@master
55
+ env:
56
+ organization_id: ${{ secrets.COCREATE_ORGANIZATION_ID }}
57
+ key: ${{ secrets.COCREATE_KEY }}
58
+ host: ${{ secrets.COCREATE_HOST }}
59
+
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [1.30.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.29.3...v1.30.0) (2023-06-07)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add @cocreate/file dependency, remove @cocreate/docs and prompt from the dependencies section, and refactor code inside the upload.js file. ([8fa20cd](https://github.com/CoCreate-app/CoCreate-cli/commit/8fa20cdbde1ab3e1d4397f41673d0d9b17c4966c))
7
+ * Install "coc" globally if not already installed ([cad848b](https://github.com/CoCreate-app/CoCreate-cli/commit/cad848bfefe2f66fb323eca3eac292d9547e6cc6))
8
+
9
+ ## [1.29.3](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.29.2...v1.29.3) (2023-06-04)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Refactor CoCreate.config.js to remove hard-coded credentials ([a332bd9](https://github.com/CoCreate-app/CoCreate-cli/commit/a332bd97114e415c36a1264d561a7efcdc51254a))
15
+
1
16
  ## [1.29.2](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.29.1...v1.29.2) (2023-06-04)
2
17
 
3
18
 
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
2
  "config": {
3
- "organization_id": "5ff747727005da1c272740ab",
4
- "key": "2061acef-0451-4545-f754-60cf8160",
5
- "host": "general.cocreate.app"
3
+ "organization_id": "",
4
+ "key": "",
5
+ "host": ""
6
6
  },
7
7
  "sources": [
8
8
  {
package/check-coc.js ADDED
@@ -0,0 +1,16 @@
1
+ const { execSync } = require('child_process');
2
+
3
+ try {
4
+ // Try to run "coc" command
5
+ execSync('coc --version', { stdio: 'ignore' });
6
+ console.log('"coc" is already installed globally.');
7
+ } catch (error) {
8
+ // If "coc" command does not exist, install it globally
9
+ console.log('"coc" command not found. Installing globally...');
10
+ try {
11
+ execSync('npm install -g coc', { stdio: 'inherit' });
12
+ console.log('"coc" has been installed globally.');
13
+ } catch (error) {
14
+ console.error('Failed to install "coc" globally:', error);
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cli",
3
- "version": "1.29.2",
3
+ "version": "1.30.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",
@@ -37,7 +37,6 @@
37
37
  "replace": "nodejs src/commands/replace.js",
38
38
  "webpack": "nodejs src/commands/fs/webpack.js",
39
39
  "docs": "node ./node_modules/@cocreate/docs/src/index.js",
40
- "hosting": "node ./node_modules/@cocreate/hosting/src/index.js",
41
40
  "permissions": "chmod +rwx /home/ubuntu/.nvm/versions/node/v19.8.1/bin/coc"
42
41
  },
43
42
  "repository": {
@@ -60,10 +59,9 @@
60
59
  },
61
60
  "dependencies": {
62
61
  "@cocreate/docs": "^1.7.15",
63
- "@cocreate/hosting": "^1.10.8",
62
+ "@cocreate/file": "^1.0.0",
64
63
  "colors": "latest",
65
64
  "glob": "^7.1.7",
66
- "prettier": "^2.3.2",
67
- "prompt": "^1.2.0"
65
+ "prettier": "^2.3.2"
68
66
  }
69
67
  }
package/repositories.js CHANGED
@@ -98,6 +98,10 @@ module.exports = [
98
98
  'path': '../CoCreate-fetch',
99
99
  'repo': 'github.com/CoCreate-app/CoCreate-fetch.git'
100
100
  },
101
+ {
102
+ 'path': '../CoCreate-file',
103
+ 'repo': 'github.com/CoCreate-app/CoCreate-file.git'
104
+ },
101
105
  {
102
106
  'path': '../CoCreate-filter',
103
107
  'repo': 'github.com/CoCreate-app/CoCreate-filter.git'
@@ -0,0 +1,66 @@
1
+ const readline = require('readline');
2
+ const { promises: fs } = require("fs");
3
+ const os = require('os');
4
+ const path = require('path');
5
+
6
+
7
+ module.exports = async function CoCreateConfig(config = {}) {
8
+
9
+ async function promptForInput(question) {
10
+ const rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout
13
+ });
14
+
15
+ return new Promise((resolve) => {
16
+ rl.question(question, (answer) => {
17
+ rl.close();
18
+ resolve(answer.trim());
19
+ });
20
+ });
21
+ }
22
+
23
+ // Check if the config file exists
24
+ const configFilePath = path.join(os.homedir(), 'CoCreateConfig.json');
25
+ try {
26
+ const configFileContent = await fs.readFile(configFilePath, 'utf8');
27
+ config = JSON.parse(configFileContent);
28
+ } catch (error) {
29
+ // Ignore error if the file doesn't exist
30
+ }
31
+
32
+ // Prompt user for organization ID if not already stored
33
+ if (!config.organization_id)
34
+ config.organization_id = await promptForInput('Enter your organization_id: ');
35
+
36
+ if (!config.host)
37
+ config.host = await promptForInput('Enter the host: ');
38
+
39
+
40
+ async function promptForSignInOrKey() {
41
+ const option = await promptForInput('Choose an option:\n1. Sign In\n2. Enter Key\n');
42
+
43
+ if (option === '1') {
44
+ if (!config.email)
45
+ config.email = await promptForInput('Enter your email: ');
46
+
47
+ if (!config.password)
48
+ config.password = await promptForInput('Enter your password: ');
49
+
50
+ } else if (option === '2') {
51
+ if (!config.key)
52
+ config.key = await promptForInput('Enter the key: ');
53
+ } else {
54
+ console.log('Invalid option. Please try again.');
55
+ await promptForSignInOrKey();
56
+ }
57
+ }
58
+ if (!config.key && (!config.email || !config.password))
59
+ await promptForSignInOrKey();
60
+
61
+
62
+ // Save the config to the file
63
+ await fs.writeFile(configFilePath, JSON.stringify(config, null, 2));
64
+
65
+ return config
66
+ }
@@ -0,0 +1,8 @@
1
+ const crud = require('@cocreate/crud-client')
2
+ const mime = require('mime-types')
3
+ const fs = require('fs');
4
+ const file = require('@cocreate/file')
5
+
6
+ module.exports = async function upload(repos, args) {
7
+ file
8
+ }
@@ -1,71 +0,0 @@
1
- let fs = require('fs');
2
- const path = require("path");
3
-
4
- module.exports = async function linkPackages(repos, args) {
5
- const failed = []
6
- const prompt = require('prompt');
7
-
8
- prompt.start();
9
-
10
- const properties = [
11
- {
12
- name: 'email',
13
- },
14
- {
15
- name: 'name',
16
- },
17
- {
18
- name: 'username',
19
- },
20
- {
21
- name: 'password',
22
- hidden: true
23
- }
24
- ];
25
-
26
- prompt.get(properties, async function (err, result) {
27
- if (err)
28
- return [{
29
- name: 'gitConfig',
30
- des: err
31
- }]
32
-
33
- await updateConfig(result);
34
- });
35
-
36
- async function updateConfig(result){
37
- (async() => {
38
- for (let repo of repos) {
39
- await update(repo, result);
40
- }
41
- console.log('finished');
42
- return failed
43
- })();
44
- }
45
-
46
- function update(param, result) {
47
- if (!param) return;
48
- let { absoutePath, name } = param;
49
- let fileContent = `[core]
50
- repositoryformatversion = 0
51
- filemode = true
52
- bare = false
53
- logallrefupdates = true
54
- [user]
55
- name = ${result.name}
56
- email = ${result.email}
57
- [remote "origin"]
58
- url = https://${result.username}:${result.password}@github.com/CoCreate-app/${name}.git
59
- fetch = +refs/heads/*:refs/remotes/origin/*
60
- [branch "master"]
61
- remote = origin
62
- merge = refs/heads/master
63
-
64
- `;
65
-
66
- let MdPath = path.resolve(absoutePath, '.git/config');
67
- if (fs.existsSync(MdPath))
68
- fs.unlinkSync(MdPath);
69
- fs.writeFileSync(MdPath, fileContent);
70
- }
71
- }
@@ -1,72 +0,0 @@
1
- let fs = require('fs');
2
- const path = require('path');
3
- const failed = [];
4
-
5
- module.exports = async function gitConfig(repos, args) {
6
- try {
7
- await getPrompts(repos);
8
- }
9
- catch (err) {
10
- failed.push({ name: 'GENERAL', des: err.message });
11
- console.error(err.red);
12
- }
13
- }
14
-
15
- async function getPrompts(repos){
16
- const prompt = require('prompt');
17
-
18
- prompt.start();
19
-
20
- const properties = [
21
- {
22
- name: 'email',
23
- },
24
- {
25
- name: 'name',
26
- },
27
- {
28
- name: 'username',
29
- },
30
- {
31
- name: 'password',
32
- hidden: true
33
- }
34
- ];
35
-
36
- prompt.get(properties, async function (err, result) {
37
- if (err) { return console.error(err); }
38
- await updateConfig(repos, result);
39
- });
40
-
41
- }
42
-
43
- async function updateConfig(repos, result){
44
- for (let meta of repos) {
45
- if (!meta) return;
46
- let fileContent = `[core]
47
- repositoryformatversion = 0
48
- filemode = true
49
- bare = false
50
- logallrefupdates = true
51
- [user]
52
- name = ${result.name}
53
- email = ${result.email}
54
- [remote "origin"]
55
- url = https://${result.username}:${result.password}@${meta.repo}
56
- fetch = +refs/heads/*:refs/remotes/origin/*
57
- [branch "master"]
58
- remote = origin
59
- merge = refs/heads/master
60
-
61
- `;
62
-
63
- let MdPath = path.resolve(meta.path, '.git/config');
64
- if (fs.existsSync(MdPath))
65
- fs.unlinkSync(MdPath);
66
- fs.writeFileSync(MdPath, fileContent);
67
- console.log('configured: ', meta.repo);
68
- }
69
- console.log('finished');
70
- return failed
71
-
72
- }