cloudcommerce 0.0.23 → 0.0.24

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.24](https://github.com/ecomplus/cloud-commerce/compare/v0.0.23...v0.0.24) (2022-07-10)
6
+
7
+
8
+ ### Features
9
+
10
+ * **cli:** Also create `.firebaserc` when `FIREBASE_PROJECT_ID` env passed (first deploy) ([7048e59](https://github.com/ecomplus/cloud-commerce/commit/7048e5961765bbd2240add5007c935518d990a0d))
11
+ * **cli:** Get Firebase project ID from `.firebaserc` or GOOGLE_APPLICATION_CREDENTIALS env (CI) ([53e4053](https://github.com/ecomplus/cloud-commerce/commit/53e40534446f1439e06d0983e32c72e6b9d6ecb5))
12
+
5
13
  ### [0.0.23](https://github.com/ecomplus/cloud-commerce/compare/v0.0.22...v0.0.23) (2022-07-09)
6
14
 
7
15
 
package/CONTRIBUTING.md CHANGED
@@ -27,7 +27,7 @@ You can skip the last three if you're willing to work with Storefront only, and
27
27
 
28
28
  #### Creating a Firebase project
29
29
 
30
- If you want to deploy to a new Firebase project:
30
+ If you want to deploy to a new Firebase project (needed for larger changes):
31
31
 
32
32
  1. Start creating new project on [Firebase console](https://console.firebase.google.com/):
33
33
  - Set a nice project name (ID) and remember it;
@@ -39,4 +39,6 @@ If you want to deploy to a new Firebase project:
39
39
 
40
40
  3. Firebase free plan doesn't support sending external HTTP requests, so you'll need to upgrade to _Blaze_ (on demand) plan;
41
41
 
42
- 4. Then run `firebase login && firebase init` and select the created project;
42
+ 4. Go to `/store` folder and edit `.firebaserc` setting your project ID (don't commit this file);
43
+
44
+ 5. Deploy with `firebase login && npm run deploy`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
6
6
  "main": "packages/api/lib/index.js",
7
7
  "author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
@@ -41,6 +41,7 @@
41
41
  "new-pkg": "bash scripts/new-package.sh",
42
42
  "build": "turbo run build",
43
43
  "test": "turbo run test",
44
- "release": "bash scripts/version-and-release.sh"
44
+ "release": "bash scripts/version-and-release.sh",
45
+ "deploy": "cd store && npm run deploy"
45
46
  }
46
47
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "functions/dist/index.js",
7
7
  "repository": {
@@ -2,8 +2,32 @@ import url from 'url';
2
2
  import path from 'path';
3
3
  import { $, argv, fs } from 'zx';
4
4
 
5
+ const { FIREBASE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS } = process.env;
5
6
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
6
7
  const pwd = process.cwd();
8
+ let projectId = FIREBASE_PROJECT_ID;
9
+ if (projectId) {
10
+ if (!fs.existsSync(path.join(pwd, '.firebaserc'))) {
11
+ fs.writeFileSync(path.join(pwd, '.firebaserc'), JSON.stringify({ projects: { default: projectId } }, null, 2));
12
+ }
13
+ } else {
14
+ if (GOOGLE_APPLICATION_CREDENTIALS) {
15
+ try {
16
+ const gac = fs.readJSONSync(path.join(pwd, GOOGLE_APPLICATION_CREDENTIALS));
17
+ projectId = gac.project_id;
18
+ } catch (e) {
19
+ //
20
+ }
21
+ }
22
+ if (!projectId) {
23
+ try {
24
+ const firebaserc = fs.readJSONSync(path.join(pwd, '.firebaserc'));
25
+ projectId = firebaserc.projects.default;
26
+ } catch (e) {
27
+ projectId = 'ecom2-hello';
28
+ }
29
+ }
30
+ }
7
31
 
8
32
  export default async () => {
9
33
  fs.copySync(path.join(__dirname, '..', 'config'), pwd);
@@ -14,7 +38,9 @@ export default async () => {
14
38
  }
15
39
  return opts;
16
40
  }, '');
17
- const $firebase = async (cmd) => $`firebase ${cmd}${options}`;
41
+ const $firebase = async (cmd) => {
42
+ return $`firebase --project=${projectId} ${cmd}${options}`;
43
+ };
18
44
  if (argv._.includes('serve')) {
19
45
  return $firebase('emulators:start');
20
46
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -2,9 +2,41 @@ import url from 'url';
2
2
  import path from 'path';
3
3
  import { $, argv, fs } from 'zx';
4
4
 
5
+ const {
6
+ FIREBASE_PROJECT_ID,
7
+ GOOGLE_APPLICATION_CREDENTIALS,
8
+ } = process.env;
9
+
5
10
  const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
6
11
  const pwd = process.cwd();
7
12
 
13
+ let projectId = FIREBASE_PROJECT_ID;
14
+ if (projectId) {
15
+ if (!fs.existsSync(path.join(pwd, '.firebaserc'))) {
16
+ fs.writeFileSync(
17
+ path.join(pwd, '.firebaserc'),
18
+ JSON.stringify({ projects: { default: projectId } }, null, 2),
19
+ );
20
+ }
21
+ } else {
22
+ if (GOOGLE_APPLICATION_CREDENTIALS) {
23
+ try {
24
+ const gac = fs.readJSONSync(path.join(pwd, GOOGLE_APPLICATION_CREDENTIALS));
25
+ projectId = gac.project_id;
26
+ } catch (e) {
27
+ //
28
+ }
29
+ }
30
+ if (!projectId) {
31
+ try {
32
+ const firebaserc = fs.readJSONSync(path.join(pwd, '.firebaserc'));
33
+ projectId = firebaserc.projects.default;
34
+ } catch (e) {
35
+ projectId = 'ecom2-hello';
36
+ }
37
+ }
38
+ }
39
+
8
40
  export default async () => {
9
41
  fs.copySync(path.join(__dirname, '..', 'config'), pwd);
10
42
 
@@ -15,7 +47,9 @@ export default async () => {
15
47
  }
16
48
  return opts;
17
49
  }, '');
18
- const $firebase = async (cmd: string) => $`firebase ${cmd}${options}`;
50
+ const $firebase = async (cmd: string) => {
51
+ return $`firebase --project=${projectId} ${cmd}${options}`;
52
+ };
19
53
 
20
54
  if (argv._.includes('serve')) {
21
55
  return $firebase('emulators:start');
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/firebase",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "src/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "main": "src/index.js",
7
7
  "repository": {
package/pnpm-lock.yaml CHANGED
@@ -88,13 +88,13 @@ importers:
88
88
 
89
89
  store:
90
90
  specifiers:
91
- '@cloudcommerce/cli': ^0.0.22
91
+ '@cloudcommerce/cli': ^0.0.23
92
92
  dependencies:
93
93
  '@cloudcommerce/cli': link:../packages/cli
94
94
 
95
95
  store/functions:
96
96
  specifiers:
97
- '@cloudcommerce/firebase': ^0.0.22
97
+ '@cloudcommerce/firebase': ^0.0.23
98
98
  dependencies:
99
99
  '@cloudcommerce/firebase': link:../../packages/firebase
100
100