@cocreate/cli 1.45.2 → 1.45.3

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.45.3](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.45.2...v1.45.3) (2023-12-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * coc upload with no args ([a638868](https://github.com/CoCreate-app/CoCreate-cli/commit/a638868b991f39c5a3bdcdcf12285d69f43824f6))
7
+
1
8
  ## [1.45.2](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.45.1...v1.45.2) (2023-12-01)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/cli",
3
- "version": "1.45.2",
3
+ "version": "1.45.3",
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",
@@ -28,65 +28,62 @@ module.exports = async function upload(directory, args) {
28
28
  console.log('Watching: ', directory)
29
29
  fs.watch(directory, { recursive: true }, async (eventType, filename) => {
30
30
  if (!filename.includes('CoCreate.config.js')) {
31
- const filePath = path.resolve(directory, filename);
32
- if (!filePath.includes('node_modules')) {
33
- const configPath = findClosestConfig(filePath);
34
- if (configPath) {
35
- const config = require(configPath);
36
-
37
- if (config) {
38
- await file(config, configPath, filePath)
39
- } else {
40
- console.log('Failed to read or parse CoCreate.config.js.');
41
- }
42
- } else {
43
- console.log('No CoCreate.config file found in parent directories.');
44
- }
31
+ const { config, configPath, filePath } = await getConfig(directory, filename);
32
+ if (config) {
33
+ await file(config, configPath, filePath)
34
+ } else {
35
+ console.log('Failed to read or parse CoCreate.config.js.');
45
36
  }
46
37
  }
47
38
  });
48
39
 
49
40
  } else {
50
- let CoCreateConfig
51
41
  if (!args.length) {
52
- let configPath = path.resolve(process.cwd(), 'CoCreate.config.js');
53
- if (!CoCreateConfig && fs.existsSync(configPath)) {
54
- CoCreateConfig = require(configPath);
42
+ directory = process.cwd()
43
+ const { config, configPath, filePath } = await getConfig(directory);
44
+ if (config) {
45
+ await file(config, configPath, filePath)
55
46
  } else {
56
- console.log('CoCreate.config.js could not be found.')
57
- process.exit()
47
+ console.log('Failed to read or parse CoCreate.config.js.');
58
48
  }
59
49
 
60
- await file(CoCreateConfig, configPath)
61
-
62
50
  } else {
63
51
  for (let arg of args) {
52
+ let CoCreateConfig
53
+
64
54
  try {
65
55
  CoCreateConfig = JSON.parse(arg)
66
56
  } catch (error) { }
67
57
 
68
58
 
69
59
  if (!CoCreateConfig) {
70
- try {
71
- let configPath = path.resolve(process.cwd(), arg)
72
- if (fs.existsSync(configPath)) {
73
- CoCreateConfig = require(configPath);
74
- if (CoCreateConfig)
75
- await file(CoCreateConfig, configPath)
76
-
77
- } else {
78
- console.log(arg + ' could not be found.')
79
- process.exit()
80
- }
81
-
82
- } catch (error) { }
60
+ const { config, configPath, filePath } = await getConfig(arg);
61
+ if (config) {
62
+ await file(config, configPath, filePath)
63
+ } else {
64
+ console.log('Failed to read or parse CoCreate.config.js.');
65
+ }
83
66
  }
84
67
  }
85
68
  }
86
69
  }
87
70
 
71
+ async function getConfig(directory, filename = '') {
72
+ const filePath = path.resolve(directory, filename);
73
+ if (!filePath.includes('node_modules')) {
74
+ const configPath = findClosestConfig(filePath)
75
+ if (configPath) {
76
+ return { config: require(configPath), configPath, filePath };
77
+
78
+ } else {
79
+ console.log('No CoCreate.config file found in parent directories.');
80
+ }
81
+ }
82
+
83
+ }
84
+
88
85
  function findClosestConfig(filePath) {
89
- let currentDir = path.dirname(filePath);
86
+ let currentDir = filePath;
90
87
 
91
88
  while (currentDir !== '/' && currentDir !== '.') {
92
89
  let configFile = path.join(currentDir, 'CoCreate.config.js');