@cloudcommerce/cli 0.0.37 → 0.0.38

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.
@@ -1,5 +1,5 @@
1
- @cloudcommerce/cli:build: cache hit, replaying output 2eb5ab719eda5391
2
- @cloudcommerce/cli:build: 
3
- @cloudcommerce/cli:build: > @cloudcommerce/cli@0.0.36 build /home/leo/code/ecomplus/cloud-commerce/packages/cli
4
- @cloudcommerce/cli:build: > sh ../../scripts/build-lib.sh
5
- @cloudcommerce/cli:build: 
1
+ @cloudcommerce/cli:build: cache hit, replaying output 9aad0748cced63bf
2
+ @cloudcommerce/cli:build: 
3
+ @cloudcommerce/cli:build: > @cloudcommerce/cli@0.0.37 build /home/leo/code/ecomplus/cloud-commerce/packages/cli
4
+ @cloudcommerce/cli:build: > sh ../../scripts/build-lib.sh
5
+ @cloudcommerce/cli:build: 
@@ -3,10 +3,28 @@
3
3
  "rules": "firestore.rules",
4
4
  "indexes": "firestore.indexes.json"
5
5
  },
6
- "functions": {
7
- "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build",
8
- "source": "functions"
9
- },
6
+ "functions": [
7
+ {
8
+ "predeploy": "npm run build -- --codebase core --dir \"$RESOURCE_DIR\"",
9
+ "source": "functions/core",
10
+ "codebase": "core"
11
+ },
12
+ {
13
+ "predeploy": "npm run build -- --codebase modules --dir \"$RESOURCE_DIR\"",
14
+ "source": "functions/modules",
15
+ "codebase": "modules"
16
+ },
17
+ {
18
+ "predeploy": "npm run build -- --codebase passport --dir \"$RESOURCE_DIR\"",
19
+ "source": "functions/passport",
20
+ "codebase": "passport"
21
+ },
22
+ {
23
+ "predeploy": "npm run build -- --codebase ssr --dir \"$RESOURCE_DIR\"",
24
+ "source": "functions/ssr",
25
+ "codebase": "ssr"
26
+ }
27
+ ],
10
28
  "hosting": {
11
29
  "public": "public",
12
30
  "ignore": [
package/lib/build.js ADDED
@@ -0,0 +1,18 @@
1
+ import path from 'path';
2
+ import { fs } from 'zx';
3
+
4
+ const copyFunctionsConfig = async () => {
5
+ const functionsDir = path.join(process.cwd(), 'functions');
6
+ const filesToCopy = ['.env', 'config.json'];
7
+ const dirents = await fs.readdir(functionsDir, { withFileTypes: true });
8
+ for (let i = 0; i < dirents.length; i++) {
9
+ if (dirents[i].isDirectory()) {
10
+ for (let ii = 0; ii < filesToCopy.length; ii++) {
11
+ // eslint-disable-next-line no-await-in-loop
12
+ await fs.copy(path.join(functionsDir, filesToCopy[ii]), path.join(functionsDir, dirents[i].name, filesToCopy[ii]));
13
+ }
14
+ }
15
+ }
16
+ };
17
+
18
+ export default copyFunctionsConfig;
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  $, argv, fs, echo, chalk,
5
5
  } from 'zx';
6
6
  import login from './login.js';
7
+ import build from './build.js';
7
8
 
8
9
  const { FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS } = process.env;
9
10
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
@@ -33,7 +34,7 @@ if (projectId) {
33
34
  }
34
35
 
35
36
  export default async () => {
36
- fs.copySync(path.join(__dirname, '..', 'config'), pwd);
37
+ await fs.copy(path.join(__dirname, '..', 'config'), pwd);
37
38
  const options = Object.keys(argv).reduce((opts, key) => {
38
39
  if (key !== '_' && key !== 'deploy' && key !== 'commit') {
39
40
  // eslint-disable-next-line no-param-reassign
@@ -62,6 +63,9 @@ ${chalk.bold('npx kill-port 4000 9099 5001 8080 5000 8085 9199 4400 4500')}
62
63
  if (argv._.find((cmd) => /^(\w+:)?logs?$/.test(cmd))) {
63
64
  return $firebase('functions:log');
64
65
  }
66
+ if (argv._.includes('build')) {
67
+ return build();
68
+ }
65
69
  if (argv._.includes('deploy')) {
66
70
  return $firebase('deploy');
67
71
  }
@@ -71,7 +75,7 @@ ${chalk.bold('npx kill-port 4000 9099 5001 8080 5000 8085 9199 4400 4500')}
71
75
  }
72
76
  if (argv._.includes('setup')) {
73
77
  const { storeId, authenticationId, apiKey } = await login();
74
- fs.writeFileSync(path.join(pwd, 'functions', '.env'), `ECOM_AUTHENTICATION_ID=${authenticationId}
78
+ await fs.writeFile(path.join(pwd, 'functions', '.env'), `ECOM_AUTHENTICATION_ID=${authenticationId}
75
79
  ECOM_API_KEY=${apiKey}
76
80
  ECOM_STORE_ID=${storeId}
77
81
  `);
@@ -79,7 +83,8 @@ ECOM_STORE_ID=${storeId}
79
83
  await $firebase('deploy');
80
84
  }
81
85
  if (argv.commit !== false) {
82
- fs.writeFileSync(path.join(pwd, 'functions', 'config.json'), JSON.stringify({ storeId }, null, 2));
86
+ await fs.writeFile(path.join(pwd, 'functions', 'config.json'), JSON.stringify({ storeId }, null, 2));
87
+ await build();
83
88
  try {
84
89
  await $`git add .firebaserc functions/config.json`;
85
90
  await $`git commit -m "Setup store [skip ci]"`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "0.0.37",
4
+ "version": "0.0.38",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/cli#readme",
25
25
  "dependencies": {
26
- "@cloudcommerce/api": "0.0.37",
26
+ "@cloudcommerce/api": "0.0.38",
27
27
  "md5": "^2.3.0",
28
28
  "zx": "^7.0.7"
29
29
  },
package/src/build.ts ADDED
@@ -0,0 +1,21 @@
1
+ import path from 'path';
2
+ import { fs } from 'zx';
3
+
4
+ const copyFunctionsConfig = async () => {
5
+ const functionsDir = path.join(process.cwd(), 'functions');
6
+ const filesToCopy = ['.env', 'config.json'];
7
+ const dirents = await fs.readdir(functionsDir, { withFileTypes: true });
8
+ for (let i = 0; i < dirents.length; i++) {
9
+ if (dirents[i].isDirectory()) {
10
+ for (let ii = 0; ii < filesToCopy.length; ii++) {
11
+ // eslint-disable-next-line no-await-in-loop
12
+ await fs.copy(
13
+ path.join(functionsDir, filesToCopy[ii]),
14
+ path.join(functionsDir, dirents[i].name, filesToCopy[ii]),
15
+ );
16
+ }
17
+ }
18
+ }
19
+ };
20
+
21
+ export default copyFunctionsConfig;
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  chalk,
9
9
  } from 'zx';
10
10
  import login from './login';
11
+ import build from './build';
11
12
 
12
13
  const {
13
14
  FIREBASE_PROJECT_ID,
@@ -45,7 +46,7 @@ if (projectId) {
45
46
  }
46
47
 
47
48
  export default async () => {
48
- fs.copySync(path.join(__dirname, '..', 'config'), pwd);
49
+ await fs.copy(path.join(__dirname, '..', 'config'), pwd);
49
50
 
50
51
  const options = Object.keys(argv).reduce((opts, key) => {
51
52
  if (key !== '_' && key !== 'deploy' && key !== 'commit') {
@@ -77,6 +78,9 @@ ${chalk.bold('npx kill-port 4000 9099 5001 8080 5000 8085 9199 4400 4500')}
77
78
  if (argv._.find((cmd) => /^(\w+:)?logs?$/.test(cmd))) {
78
79
  return $firebase('functions:log');
79
80
  }
81
+ if (argv._.includes('build')) {
82
+ return build();
83
+ }
80
84
  if (argv._.includes('deploy')) {
81
85
  return $firebase('deploy');
82
86
  }
@@ -87,7 +91,7 @@ ${chalk.bold('npx kill-port 4000 9099 5001 8080 5000 8085 9199 4400 4500')}
87
91
 
88
92
  if (argv._.includes('setup')) {
89
93
  const { storeId, authenticationId, apiKey } = await login();
90
- fs.writeFileSync(
94
+ await fs.writeFile(
91
95
  path.join(pwd, 'functions', '.env'),
92
96
  `ECOM_AUTHENTICATION_ID=${authenticationId}
93
97
  ECOM_API_KEY=${apiKey}
@@ -98,10 +102,11 @@ ECOM_STORE_ID=${storeId}
98
102
  await $firebase('deploy');
99
103
  }
100
104
  if (argv.commit !== false) {
101
- fs.writeFileSync(
105
+ await fs.writeFile(
102
106
  path.join(pwd, 'functions', 'config.json'),
103
107
  JSON.stringify({ storeId }, null, 2),
104
108
  );
109
+ await build();
105
110
  try {
106
111
  await $`git add .firebaserc functions/config.json`;
107
112
  await $`git commit -m "Setup store [skip ci]"`;