cloudcommerce 0.0.29 → 0.0.30
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 +13 -0
- package/CONTRIBUTING.md +18 -0
- package/action.yml +10 -3
- package/package.json +6 -5
- package/packages/api/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/cli/lib/index.js +5 -2
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/index.ts +8 -5
- package/packages/firebase/lib/index.js +17 -2
- package/packages/firebase/lib/index.js.map +1 -1
- package/packages/firebase/lib/methods/check-store-events.js +18 -0
- package/packages/firebase/lib/methods/check-store-events.js.map +1 -0
- package/packages/firebase/lib/types.js +3 -0
- package/packages/firebase/lib/types.js.map +1 -0
- package/packages/firebase/package.json +1 -1
- package/packages/firebase/src/index.ts +23 -3
- package/packages/firebase/src/methods/check-store-events.ts +18 -0
- package/packages/firebase/src/types.ts +12 -0
- package/packages/storefront/package.json +2 -2
- package/pnpm-lock.yaml +222 -524
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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.30](https://github.com/ecomplus/cloud-commerce/compare/v0.0.29...v0.0.30) (2022-07-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **firebase:** Start listing stor eevents (orders, carts, products) with new cron function ([2eb0616](https://github.com/ecomplus/cloud-commerce/commit/2eb06168b03e7cd751c58001cf36c8253da040d7))
|
|
11
|
+
* GH Action setup functions .env with repo secrets ([98bf2a2](https://github.com/ecomplus/cloud-commerce/commit/98bf2a2ba25edd45da32555fa6e18fab3b459be8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **cli:** Do not change `config.json with `--no-commit` option ([f94ca57](https://github.com/ecomplus/cloud-commerce/commit/f94ca5740d16412a0c07537d512632f5d12a5904))
|
|
17
|
+
|
|
5
18
|
### [0.0.29](https://github.com/ecomplus/cloud-commerce/compare/v0.0.28...v0.0.29) (2022-07-17)
|
|
6
19
|
|
|
7
20
|
### [0.0.28](https://github.com/ecomplus/cloud-commerce/compare/v0.0.27...v0.0.28) (2022-07-17)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -12,6 +12,7 @@ Clone this repo to your local machine and install the dependencies:
|
|
|
12
12
|
|
|
13
13
|
```console
|
|
14
14
|
git clone --recurse-submodules git@github.com:ecomplus/cloud-commerce.git
|
|
15
|
+
cd cloud-commerce
|
|
15
16
|
pnpm install
|
|
16
17
|
```
|
|
17
18
|
|
|
@@ -43,3 +44,20 @@ If you want to deploy to a new Firebase project (needed for larger changes):
|
|
|
43
44
|
4. Go to `/store` folder and edit `.firebaserc` setting your project ID (don't commit this file);
|
|
44
45
|
|
|
45
46
|
5. Deploy with `firebase login && npm run deploy`;
|
|
47
|
+
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
To emulate Firebase and serve all starter Store services locally, run the following commands on the monorepo root:
|
|
51
|
+
|
|
52
|
+
```console
|
|
53
|
+
pnpm run setup
|
|
54
|
+
pnpm serve
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`run setup` is only needed for the first time, it'll get your store credentials and put them in `functions/.env`.
|
|
58
|
+
|
|
59
|
+
To run tests for all packages:
|
|
60
|
+
|
|
61
|
+
```console
|
|
62
|
+
pnpm test
|
|
63
|
+
```
|
package/action.yml
CHANGED
|
@@ -38,10 +38,17 @@ runs:
|
|
|
38
38
|
shell: bash
|
|
39
39
|
env:
|
|
40
40
|
FIREBASE_SERVICE_ACCOUNT: ${{ inputs.firebase-service-account }}
|
|
41
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
42
|
+
ECOM_AUTHENTICATION_ID: ${{ secrets.ECOM_AUTHENTICATION_ID }}
|
|
43
|
+
ECOM_API_KEY: ${{ secrets.ECOM_API_KEY }}
|
|
41
44
|
run: |
|
|
42
|
-
export GAC_FILENAME=".gac-$RANDOM.json"
|
|
43
|
-
echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME
|
|
44
|
-
|
|
45
|
+
export GAC_FILENAME=".gac-$RANDOM.json"
|
|
46
|
+
echo $FIREBASE_SERVICE_ACCOUNT > $GAC_FILENAME
|
|
47
|
+
printf "ECOM_AUTHENTICATION_ID=$ECOM_AUTHENTICATION_ID
|
|
48
|
+
ECOM_API_KEY=$ECOM_API_KEY
|
|
49
|
+
GITHUB_TOKEN=$GITHUB_TOKEN
|
|
50
|
+
" > functions/.env
|
|
51
|
+
GOOGLE_APPLICATION_CREDENTIALS=$GAC_FILENAME npm run deploy
|
|
45
52
|
|
|
46
53
|
- if: github.event_name == 'pull_request'
|
|
47
54
|
name: Deploy Firebase Hosting PR preview
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcommerce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.30",
|
|
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>",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"@commitlint/config-conventional": "^17.0.3",
|
|
21
21
|
"@commitlint/rules": "^17.0.0",
|
|
22
22
|
"@types/node": "^18.0.5",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
24
|
-
"@typescript-eslint/parser": "^5.30.
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
24
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
25
25
|
"esbuild": "^0.14.49",
|
|
26
26
|
"eslint": "^8.20.0",
|
|
27
27
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
29
|
"eslint-plugin-vue": "^9.2.0",
|
|
30
30
|
"husky": "^8.0.1",
|
|
31
|
-
"node-fetch": "^3.2.
|
|
31
|
+
"node-fetch": "^3.2.9",
|
|
32
32
|
"standard-version": "^9.5.0",
|
|
33
33
|
"turbo": "^1.3.1",
|
|
34
34
|
"typescript": "^4.7.4",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"store:run": "pnpm build && npm --prefix \"store\" run",
|
|
46
46
|
"start": "pnpm store:run start",
|
|
47
47
|
"serve": "pnpm store:run serve",
|
|
48
|
-
"deploy": "pnpm store:run deploy"
|
|
48
|
+
"deploy": "pnpm store:run deploy",
|
|
49
|
+
"setup": "pnpm store:run setup:quiet"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -62,12 +62,15 @@ export default async () => {
|
|
|
62
62
|
}
|
|
63
63
|
if (argv._.includes('setup')) {
|
|
64
64
|
const { storeId, authenticationId, apiKey } = await login();
|
|
65
|
-
fs.writeFileSync(path.join(pwd, 'functions', '
|
|
66
|
-
|
|
65
|
+
fs.writeFileSync(path.join(pwd, 'functions', '.env'), `ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
66
|
+
ECOM_API_KEY=${apiKey}
|
|
67
|
+
ECOM_STORE_ID=${storeId}
|
|
68
|
+
`);
|
|
67
69
|
if (argv.deploy !== false) {
|
|
68
70
|
await $firebase('deploy');
|
|
69
71
|
}
|
|
70
72
|
if (argv.commit !== false) {
|
|
73
|
+
fs.writeFileSync(path.join(pwd, 'functions', 'config.json'), JSON.stringify({ storeId }, null, 2));
|
|
71
74
|
try {
|
|
72
75
|
await $`git add .firebaserc functions/config.json`;
|
|
73
76
|
await $`git commit -m "Setup store [skip ci]"`;
|
|
@@ -78,18 +78,21 @@ export default async () => {
|
|
|
78
78
|
|
|
79
79
|
if (argv._.includes('setup')) {
|
|
80
80
|
const { storeId, authenticationId, apiKey } = await login();
|
|
81
|
-
fs.writeFileSync(
|
|
82
|
-
path.join(pwd, 'functions', 'config.json'),
|
|
83
|
-
JSON.stringify({ storeId }, null, 2),
|
|
84
|
-
);
|
|
85
81
|
fs.writeFileSync(
|
|
86
82
|
path.join(pwd, 'functions', '.env'),
|
|
87
|
-
`ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
83
|
+
`ECOM_AUTHENTICATION_ID=${authenticationId}
|
|
84
|
+
ECOM_API_KEY=${apiKey}
|
|
85
|
+
ECOM_STORE_ID=${storeId}
|
|
86
|
+
`,
|
|
88
87
|
);
|
|
89
88
|
if (argv.deploy !== false) {
|
|
90
89
|
await $firebase('deploy');
|
|
91
90
|
}
|
|
92
91
|
if (argv.commit !== false) {
|
|
92
|
+
fs.writeFileSync(
|
|
93
|
+
path.join(pwd, 'functions', 'config.json'),
|
|
94
|
+
JSON.stringify({ storeId }, null, 2),
|
|
95
|
+
);
|
|
93
96
|
try {
|
|
94
97
|
await $`git add .firebaserc functions/config.json`;
|
|
95
98
|
await $`git commit -m "Setup store [skip ci]"`;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import 'source-map-support/register.js';
|
|
2
|
-
import { logger } from 'firebase-functions';
|
|
2
|
+
import { pubsub, logger } from 'firebase-functions';
|
|
3
3
|
// eslint-disable-next-line import/no-unresolved
|
|
4
4
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
5
5
|
import config from './config.js';
|
|
6
|
+
import checkStoreEvents from './methods/check-store-events.js';
|
|
6
7
|
|
|
8
|
+
const { AUTHENTICATION_ID, API_KEY, GITHUB_TOKEN } = process.env;
|
|
9
|
+
if (!AUTHENTICATION_ID || !API_KEY || !GITHUB_TOKEN) {
|
|
10
|
+
throw new Error('Missing environment variables');
|
|
11
|
+
}
|
|
12
|
+
const processId = String(Date.now());
|
|
13
|
+
const env = {
|
|
14
|
+
processId,
|
|
15
|
+
authenticationId: AUTHENTICATION_ID,
|
|
16
|
+
apiKey: API_KEY,
|
|
17
|
+
githubToken: GITHUB_TOKEN,
|
|
18
|
+
};
|
|
7
19
|
const options = {
|
|
8
20
|
region: process.env.DEPLOY_REGION || 'us-east1',
|
|
9
21
|
};
|
|
10
|
-
const processId = String(Date.now());
|
|
11
22
|
|
|
12
23
|
export const z = onRequest(options, ({ url }, response) => {
|
|
13
24
|
if (url === '/hello') {
|
|
@@ -29,4 +40,8 @@ export const z = onRequest(options, ({ url }, response) => {
|
|
|
29
40
|
export const ssr = onRequest(options, (request, response) => {
|
|
30
41
|
response.send('<h1>Hello SSR!</h1>');
|
|
31
42
|
});
|
|
43
|
+
|
|
44
|
+
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
|
|
45
|
+
return checkStoreEvents(env);
|
|
46
|
+
});
|
|
32
47
|
// # sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,MAAM,EACJ,iBAAiB,EACjB,OAAO,EACP,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAC;AAChB,IAAI,CAAC,iBAAiB,IAAI,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE;IACnD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;CAClD;AACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AACrC,MAAM,GAAG,GAAQ;IACf,SAAS;IAC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
+
'orders',
|
|
7
|
+
'products',
|
|
8
|
+
'carts',
|
|
9
|
+
].forEach(async (resource) => {
|
|
10
|
+
const { data: { result } } = await api({
|
|
11
|
+
authenticationId,
|
|
12
|
+
apiKey,
|
|
13
|
+
endpoint: `events/${resource}`,
|
|
14
|
+
});
|
|
15
|
+
logger.info(`${resource} events: `, result);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
// # sourceMappingURL=check-store-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-store-events.js","sourceRoot":"","sources":["../../src/methods/check-store-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,eAAe,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAO,EAAE,EAAE;IACzD;QACE,QAAQ;QACR,UAAU;QACV,OAAO;KACR,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC3B,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC;YACrC,gBAAgB;YAChB,MAAM;YACN,QAAQ,EAAE,UAAU,QAAoB,EAAE;SAC3C,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,iDAAiD"}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
+
import type { Env } from './types';
|
|
1
2
|
import 'source-map-support/register.js';
|
|
2
|
-
import { logger } from 'firebase-functions';
|
|
3
|
+
import { pubsub, logger } from 'firebase-functions';
|
|
3
4
|
// eslint-disable-next-line import/no-unresolved
|
|
4
5
|
import { onRequest } from 'firebase-functions/v2/https';
|
|
5
6
|
import config from './config';
|
|
7
|
+
import checkStoreEvents from './methods/check-store-events';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
AUTHENTICATION_ID,
|
|
11
|
+
API_KEY,
|
|
12
|
+
GITHUB_TOKEN,
|
|
13
|
+
} = process.env;
|
|
14
|
+
if (!AUTHENTICATION_ID || !API_KEY || !GITHUB_TOKEN) {
|
|
15
|
+
throw new Error('Missing environment variables');
|
|
16
|
+
}
|
|
17
|
+
const processId = String(Date.now());
|
|
18
|
+
const env: Env = {
|
|
19
|
+
processId,
|
|
20
|
+
authenticationId: AUTHENTICATION_ID,
|
|
21
|
+
apiKey: API_KEY,
|
|
22
|
+
githubToken: GITHUB_TOKEN,
|
|
23
|
+
};
|
|
6
24
|
|
|
7
25
|
const options = {
|
|
8
26
|
region: process.env.DEPLOY_REGION || 'us-east1',
|
|
9
27
|
};
|
|
10
28
|
|
|
11
|
-
const processId = String(Date.now());
|
|
12
|
-
|
|
13
29
|
export const z = onRequest(options, ({ url }, response) => {
|
|
14
30
|
if (url === '/hello') {
|
|
15
31
|
logger.info('Hello logs!', {
|
|
@@ -30,3 +46,7 @@ export const z = onRequest(options, ({ url }, response) => {
|
|
|
30
46
|
export const ssr = onRequest(options, (request, response) => {
|
|
31
47
|
response.send('<h1>Hello SSR!</h1>');
|
|
32
48
|
});
|
|
49
|
+
|
|
50
|
+
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
|
|
51
|
+
return checkStoreEvents(env);
|
|
52
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Env } from '../types';
|
|
2
|
+
import { logger } from 'firebase-functions';
|
|
3
|
+
import api from '@cloudcommerce/api';
|
|
4
|
+
|
|
5
|
+
export default async ({ authenticationId, apiKey }: Env) => {
|
|
6
|
+
[
|
|
7
|
+
'orders',
|
|
8
|
+
'products',
|
|
9
|
+
'carts',
|
|
10
|
+
].forEach(async (resource) => {
|
|
11
|
+
const { data: { result } } = await api({
|
|
12
|
+
authenticationId,
|
|
13
|
+
apiKey,
|
|
14
|
+
endpoint: `events/${resource as 'orders'}`,
|
|
15
|
+
});
|
|
16
|
+
logger.info(`${resource} events: `, result);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/storefront",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.30",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront with Astro",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@cloudcommerce/api": "workspace:*",
|
|
23
|
-
"astro": "1.0.0-beta.
|
|
23
|
+
"astro": "1.0.0-beta.72"
|
|
24
24
|
}
|
|
25
25
|
}
|