cloudcommerce 0.0.21 → 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,29 @@
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
+
13
+ ### [0.0.23](https://github.com/ecomplus/cloud-commerce/compare/v0.0.22...v0.0.23) (2022-07-09)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * GH Action also install functions dependencies to deploy ([9321030](https://github.com/ecomplus/cloud-commerce/commit/93210305453b10174a0c586e70614f5d869e46ab))
19
+
20
+ ### [0.0.22](https://github.com/ecomplus/cloud-commerce/compare/v0.0.21...v0.0.22) (2022-07-09)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **cli:** Run `firebase` instead of `npx firebase-tools` ([f0f4be5](https://github.com/ecomplus/cloud-commerce/commit/f0f4be5f55fa6552dc9ed142b253f8119defb296))
26
+ * **gh-action:** Install `firebase-tools` with specific semver ([51e175f](https://github.com/ecomplus/cloud-commerce/commit/51e175f5c4227badcb868a9ee2bdaaa09b3b0017))
27
+
5
28
  ### [0.0.21](https://github.com/ecomplus/cloud-commerce/compare/v0.0.20...v0.0.21) (2022-07-09)
6
29
 
7
30
 
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/action.yml CHANGED
@@ -14,16 +14,22 @@ outputs: {}
14
14
  runs:
15
15
  using: "composite"
16
16
  steps:
17
- - if: github.event_name == 'push'
18
- uses: actions/setup-node@v3
17
+ - uses: actions/setup-node@v3
19
18
  with:
20
19
  node-version: 16
21
20
  cache: 'npm'
22
21
 
23
22
  - if: github.event_name == 'push'
24
23
  shell: bash
25
- run: npm i -g firebase-tools && npm ci
26
-
24
+ run: npm i --location=global firebase-tools@^11.2.1
25
+
26
+ - shell: bash
27
+ run: npm ci --only=production
28
+
29
+ - shell: bash
30
+ working-directory: functions
31
+ run: npm ci --only=production --no-optional
32
+
27
33
  - shell: bash
28
34
  run: npm run build
29
35
 
@@ -36,7 +42,7 @@ runs:
36
42
  export GAC_FILENAME=".gac-$RANDOM.json";
37
43
  echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME;
38
44
  GOOGLE_APPLICATION_CREDENTIALS=$GAC_FILENAME npm run deploy;
39
-
45
+
40
46
  - if: github.event_name == 'pull_request'
41
47
  name: Deploy Firebase Hosting PR preview
42
48
  uses: FirebaseExtended/action-hosting-deploy@v0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.21",
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.21",
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.21",
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) => $`npx firebase-tools ${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.21",
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) => $`npx firebase-tools ${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.21",
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.21",
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": {