cloudcommerce 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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/packages/api/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/cli/config/firebase.json +22 -4
- package/packages/cli/lib/build.js +18 -0
- package/packages/cli/lib/index.js +8 -3
- package/packages/cli/package.json +1 -1
- package/packages/cli/src/build.ts +21 -0
- package/packages/cli/src/index.ts +8 -3
- package/packages/firebase/lib/config.js +18 -22
- package/packages/firebase/lib/defaults.js +1 -4
- package/packages/firebase/lib/env.js +17 -17
- package/packages/firebase/lib/handlers/check-store-events.js +23 -24
- package/packages/firebase/lib/index.js +2 -4
- package/packages/firebase/lib/types.js +1 -1
- package/packages/firebase/package.json +2 -2
- package/packages/modules/firebase.js +1 -0
- package/packages/modules/package.json +1 -1
- package/packages/passport/firebase.js +1 -0
- package/packages/passport/package.json +1 -1
- package/packages/ssr/firebase.js +1 -0
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/pnpm-lock.yaml +3 -3
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.38](https://github.com/ecomplus/cloud-commerce/compare/v0.0.37...v0.0.38) (2022-07-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* Add root `firebase.js` as complement to pkg named export to prevent no-unresolved eslint error ([a65587b](https://github.com/ecomplus/cloud-commerce/commit/a65587b840015aa9224df2458eb5b10385002c81))
|
|
11
|
+
* **firebase:** Edit `/config` pkg export to `./lib/config.js` to get TS declaration ([b873572](https://github.com/ecomplus/cloud-commerce/commit/b873572e16162094249f6bdc6a25ec8c1b344111))
|
|
12
|
+
|
|
5
13
|
### [0.0.37](https://github.com/ecomplus/cloud-commerce/compare/v0.0.36...v0.0.37) (2022-07-27)
|
|
6
14
|
|
|
7
15
|
|
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.38",
|
|
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>",
|
|
@@ -3,10 +3,28 @@
|
|
|
3
3
|
"rules": "firestore.rules",
|
|
4
4
|
"indexes": "firestore.indexes.json"
|
|
5
5
|
},
|
|
6
|
-
"functions":
|
|
7
|
-
|
|
8
|
-
|
|
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": [
|
|
@@ -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;
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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]"`;
|
|
@@ -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;
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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]"`;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import Deepmerge from '@fastify/deepmerge';
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_LANG, DEFAULT_CURRENCY, DEFAULT_CURRENCY_SYMBOL, DEFAULT_COUNTRY_CODE,
|
|
4
|
-
} from './defaults.js';
|
|
5
|
-
|
|
2
|
+
import { DEFAULT_LANG, DEFAULT_CURRENCY, DEFAULT_CURRENCY_SYMBOL, DEFAULT_COUNTRY_CODE, } from './defaults.js';
|
|
6
3
|
const deepmerge = Deepmerge();
|
|
7
4
|
const self = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
__config: {
|
|
6
|
+
hello: 'from @cloudcommerce/firebase',
|
|
7
|
+
lang: process.env.ECOM_LANG || DEFAULT_LANG,
|
|
8
|
+
currency: process.env.ECOM_CURRENCY || DEFAULT_CURRENCY,
|
|
9
|
+
currencySymbol: process.env.ECOM_CURRENCY_SYMBOL || DEFAULT_CURRENCY_SYMBOL,
|
|
10
|
+
countryCode: process.env.ECOM_COUNTRY_CODE || DEFAULT_COUNTRY_CODE,
|
|
11
|
+
storeId: Number(process.env.ECOM_STORE_ID),
|
|
12
|
+
httpsFunctionOptions: {
|
|
13
|
+
region: process.env.DEPLOY_REGION || 'us-east1',
|
|
14
|
+
},
|
|
17
15
|
},
|
|
18
|
-
},
|
|
19
16
|
};
|
|
20
|
-
|
|
21
17
|
export default {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
get() {
|
|
19
|
+
return self.__config;
|
|
20
|
+
},
|
|
21
|
+
set(config) {
|
|
22
|
+
self.__config = deepmerge(self.__config, config);
|
|
23
|
+
},
|
|
28
24
|
};
|
|
29
|
-
|
|
25
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export default () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
const { ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN, } = process.env;
|
|
3
|
+
if (!ECOM_AUTHENTICATION_ID) {
|
|
4
|
+
throw new Error('ECOM_AUTHENTICATION_ID is not set');
|
|
5
|
+
}
|
|
6
|
+
if (!ECOM_API_KEY) {
|
|
7
|
+
throw new Error('ECOM_API_KEY is not set');
|
|
8
|
+
}
|
|
9
|
+
const authenticationId = ECOM_AUTHENTICATION_ID;
|
|
10
|
+
const apiKey = ECOM_API_KEY;
|
|
11
|
+
const githubToken = GITHUB_TOKEN;
|
|
12
|
+
const env = {
|
|
13
|
+
authenticationId,
|
|
14
|
+
apiKey,
|
|
15
|
+
githubToken,
|
|
16
|
+
};
|
|
17
|
+
return env;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -3,30 +3,29 @@ import { getFirestore } from 'firebase-admin/firestore';
|
|
|
3
3
|
import { logger } from 'firebase-functions';
|
|
4
4
|
import api from '@cloudcommerce/api';
|
|
5
5
|
import getEnv from '../env.js';
|
|
6
|
-
|
|
7
6
|
export default async () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
logger.info({ listenedEvents });
|
|
18
|
-
[
|
|
19
|
-
'orders',
|
|
20
|
-
'products',
|
|
21
|
-
'carts',
|
|
22
|
-
].forEach(async (resource) => {
|
|
23
|
-
const { data: { result } } = await api({
|
|
24
|
-
authenticationId,
|
|
25
|
-
apiKey,
|
|
26
|
-
endpoint: `events/${resource}`,
|
|
7
|
+
const { authenticationId, apiKey } = getEnv();
|
|
8
|
+
const eventsSubs = await getFirestore().collection('eventsSubs').get();
|
|
9
|
+
const listenedEvents = [];
|
|
10
|
+
eventsSubs.forEach((doc) => {
|
|
11
|
+
const eventSub = doc.data();
|
|
12
|
+
if (!listenedEvents.includes(eventSub.event)) {
|
|
13
|
+
listenedEvents.push(eventSub.event);
|
|
14
|
+
}
|
|
27
15
|
});
|
|
28
|
-
logger.info(
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
logger.info({ listenedEvents });
|
|
17
|
+
[
|
|
18
|
+
'orders',
|
|
19
|
+
'products',
|
|
20
|
+
'carts',
|
|
21
|
+
].forEach(async (resource) => {
|
|
22
|
+
const { data: { result } } = await api({
|
|
23
|
+
authenticationId,
|
|
24
|
+
apiKey,
|
|
25
|
+
endpoint: `events/${resource}`,
|
|
26
|
+
});
|
|
27
|
+
logger.info(`${resource} events: `, result);
|
|
28
|
+
});
|
|
29
|
+
return true;
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
//# sourceMappingURL=check-store-events.js.map
|
|
@@ -6,10 +6,8 @@ import '@cloudcommerce/api/fetch-polyfill.js';
|
|
|
6
6
|
import { initializeApp } from 'firebase-admin/app';
|
|
7
7
|
import { pubsub } from 'firebase-functions';
|
|
8
8
|
import checkStoreEvents from './handlers/check-store-events.js';
|
|
9
|
-
|
|
10
9
|
initializeApp();
|
|
11
|
-
|
|
12
10
|
export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
|
|
13
|
-
|
|
11
|
+
return checkStoreEvents();
|
|
14
12
|
});
|
|
15
|
-
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.38",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce on Firebase",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./lib/index.js",
|
|
10
|
-
"./config": "./config.js"
|
|
10
|
+
"./config": "./lib/config.js"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/firebase.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/firebase.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/firebase.js';
|
package/pnpm-lock.yaml
CHANGED
|
@@ -118,7 +118,7 @@ importers:
|
|
|
118
118
|
packages/passport:
|
|
119
119
|
specifiers:
|
|
120
120
|
'@cloudcommerce/api': workspace:*
|
|
121
|
-
'@cloudcommerce/firebase': workspace
|
|
121
|
+
'@cloudcommerce/firebase': workspace:*
|
|
122
122
|
'@cloudcommerce/types': workspace:*
|
|
123
123
|
'@firebase/app-types': ^0.7.0
|
|
124
124
|
firebase-admin: ^11.0.0
|
|
@@ -171,13 +171,13 @@ importers:
|
|
|
171
171
|
|
|
172
172
|
store:
|
|
173
173
|
specifiers:
|
|
174
|
-
'@cloudcommerce/cli': ^0.0.
|
|
174
|
+
'@cloudcommerce/cli': ^0.0.37
|
|
175
175
|
dependencies:
|
|
176
176
|
'@cloudcommerce/cli': link:../packages/cli
|
|
177
177
|
|
|
178
178
|
store/functions:
|
|
179
179
|
specifiers:
|
|
180
|
-
'@cloudcommerce/firebase': ^0.0.
|
|
180
|
+
'@cloudcommerce/firebase': ^0.0.37
|
|
181
181
|
dependencies:
|
|
182
182
|
'@cloudcommerce/firebase': link:../../packages/firebase
|
|
183
183
|
|