@raisenow/tamaro-cli 1.0.25 → 1.1.0
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/.eslintignore +3 -0
- package/.eslintrc.cjs +142 -42
- package/.nvmrc +1 -1
- package/.prettierignore +3 -0
- package/README.md +14 -22
- package/dist/{chunk-XC5QT3RG.js → chunk-S4M23KNZ.js} +64 -44
- package/dist/cli.js +334 -322
- package/dist/webpack.config.js +54 -22
- package/package.json +64 -54
- package/readme.html +1 -1
- package/src/cli.ts +12 -44
- package/src/commands/build.ts +23 -15
- package/src/commands/deploy-email-config.ts +19 -52
- package/src/commands/deploy.ts +18 -19
- package/src/commands/dev.ts +9 -6
- package/src/commands/list-deployed.ts +15 -20
- package/src/commands/serve.ts +3 -3
- package/src/lib/InterpolateHtmlPlugin.ts +7 -7
- package/src/lib/aws.ts +72 -26
- package/src/lib/command.ts +5 -1
- package/src/lib/constants.ts +2 -1
- package/src/lib/env.ts +43 -28
- package/src/lib/https.ts +2 -2
- package/src/lib/logging.ts +9 -4
- package/src/lib/resolve.ts +5 -7
- package/src/webpack.config.ts +21 -20
- package/tsconfig.json +5 -1
- package/.gitignore +0 -14
- package/tsconfig.eslint.json +0 -7
package/.eslintignore
CHANGED
package/.eslintrc.cjs
CHANGED
|
@@ -1,47 +1,147 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
overrides: [
|
|
4
|
+
{
|
|
5
|
+
files: ['*.{js,cjs,ts}'],
|
|
6
|
+
env: {
|
|
7
|
+
node: true,
|
|
8
|
+
es2021: true,
|
|
9
|
+
},
|
|
10
|
+
settings: {
|
|
11
|
+
'import/resolver': {
|
|
12
|
+
typescript: {
|
|
13
|
+
alwaysTryTypes: true,
|
|
14
|
+
project: ['./tsconfig.json'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
parser: '@typescript-eslint/parser',
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaVersion: 2021,
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
tsconfigRootDir: __dirname,
|
|
23
|
+
project: ['./tsconfig.json'],
|
|
24
|
+
extraFileExtensions: ['.cjs'],
|
|
25
|
+
},
|
|
26
|
+
extends: [
|
|
27
|
+
'eslint:recommended',
|
|
28
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
29
|
+
'plugin:@typescript-eslint/strict-type-checked',
|
|
30
|
+
'plugin:@typescript-eslint/stylistic-type-checked',
|
|
31
|
+
'plugin:promise/recommended',
|
|
32
|
+
'plugin:deprecation/recommended',
|
|
33
|
+
'plugin:import/recommended',
|
|
34
|
+
'plugin:import/typescript',
|
|
35
|
+
'prettier',
|
|
36
|
+
],
|
|
37
|
+
plugins: ['unused-imports'],
|
|
38
|
+
rules: {
|
|
39
|
+
curly: 1,
|
|
40
|
+
'prefer-const': 1,
|
|
41
|
+
'no-console': 1,
|
|
42
|
+
strict: 1,
|
|
43
|
+
'no-debugger': 1,
|
|
44
|
+
|
|
45
|
+
'no-extra-boolean-cast': 0,
|
|
46
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
47
|
+
'@typescript-eslint/no-non-null-assertion': 0,
|
|
48
|
+
'@typescript-eslint/no-unsafe-assignment': 0,
|
|
49
|
+
'@typescript-eslint/no-unsafe-argument': 0,
|
|
50
|
+
'@typescript-eslint/no-unsafe-member-access': 0,
|
|
51
|
+
'@typescript-eslint/no-unsafe-return': 0,
|
|
52
|
+
// '@typescript-eslint/no-unsafe-enum-comparison': 0,
|
|
53
|
+
// '@typescript-eslint/no-unsafe-call': 0,
|
|
54
|
+
// '@typescript-eslint/explicit-function-return-type': 0,
|
|
55
|
+
'@typescript-eslint/consistent-type-definitions': 0,
|
|
56
|
+
// '@typescript-eslint/no-dynamic-delete': 0,
|
|
57
|
+
|
|
58
|
+
'@typescript-eslint/ban-ts-comment': [2, {'ts-expect-error': false}],
|
|
59
|
+
'@typescript-eslint/no-unused-vars': [1, {varsIgnorePattern: '^_'}],
|
|
60
|
+
'@typescript-eslint/prefer-optional-chain': 1,
|
|
61
|
+
'@typescript-eslint/member-delimiter-style': [
|
|
62
|
+
1,
|
|
63
|
+
{multiline: {delimiter: 'none'}},
|
|
64
|
+
],
|
|
65
|
+
|
|
66
|
+
'@typescript-eslint/no-confusing-void-expression': [
|
|
67
|
+
2,
|
|
68
|
+
{ignoreArrowShorthand: true},
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
'import/newline-after-import': 2,
|
|
72
|
+
|
|
73
|
+
'unused-imports/no-unused-imports': 1,
|
|
74
|
+
|
|
75
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
76
|
+
2,
|
|
77
|
+
{
|
|
78
|
+
prefer: 'type-imports',
|
|
79
|
+
fixStyle: 'inline-type-imports',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
'sort-imports': [2, {ignoreCase: true, ignoreDeclarationSort: true}],
|
|
84
|
+
'import/order': [
|
|
85
|
+
2,
|
|
86
|
+
{
|
|
87
|
+
groups: [
|
|
88
|
+
'builtin',
|
|
89
|
+
'external',
|
|
90
|
+
'internal',
|
|
91
|
+
['parent', 'sibling', 'index'],
|
|
92
|
+
],
|
|
93
|
+
pathGroups: [
|
|
94
|
+
{
|
|
95
|
+
pattern: '**/*.json',
|
|
96
|
+
group: 'unknown',
|
|
97
|
+
position: 'after',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
pattern: '**/*.yml',
|
|
101
|
+
group: 'unknown',
|
|
102
|
+
position: 'after',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
distinctGroup: false,
|
|
106
|
+
alphabetize: {
|
|
107
|
+
order: 'asc',
|
|
108
|
+
orderImportKind: 'asc',
|
|
109
|
+
caseInsensitive: true,
|
|
110
|
+
},
|
|
111
|
+
'newlines-between': 'never',
|
|
112
|
+
|
|
113
|
+
// Since docs for "pathGroupsExcludedImportTypes" option are confusing,
|
|
114
|
+
// see more info about how to correctly use it here:
|
|
115
|
+
// https://github.com/import-js/eslint-plugin-import/pull/2156#issuecomment-927559466
|
|
116
|
+
pathGroupsExcludedImportTypes: [],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
files: ['*.{yml,yaml}'],
|
|
123
|
+
extends: ['plugin:yml/standard'],
|
|
124
|
+
rules: {
|
|
125
|
+
// 'yml/no-irregular-whitespace': 0,
|
|
126
|
+
// 'yml/quotes': [2, {prefer: 'double', avoidEscape: true}],
|
|
127
|
+
'yml/plain-scalar': 0,
|
|
128
|
+
'yml/no-multiple-empty-lines': [2, {max: 1}],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
files: ['*.md'],
|
|
133
|
+
parser: 'eslint-plugin-markdownlint/parser',
|
|
134
|
+
extends: ['plugin:markdownlint/recommended'],
|
|
135
|
+
rules: {
|
|
136
|
+
// Rules docs:
|
|
137
|
+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
|
|
138
|
+
|
|
139
|
+
'markdownlint/md013': 0, // Line length
|
|
140
|
+
'markdownlint/md024': [2, {siblings_only: true}], // Multiple headings with the same content
|
|
141
|
+
'markdownlint/md025': 0, // Multiple top-level headings in the same document
|
|
142
|
+
'markdownlint/md033': 0, // Inline HTML
|
|
143
|
+
'markdownlint/md041': 0, // First line in a file should be a top-level heading
|
|
144
|
+
},
|
|
12
145
|
},
|
|
13
|
-
ecmaVersion: 2021,
|
|
14
|
-
sourceType: 'module',
|
|
15
|
-
tsconfigRootDir: __dirname,
|
|
16
|
-
project: './tsconfig.eslint.json',
|
|
17
|
-
extraFileExtensions: ['.cjs'],
|
|
18
|
-
},
|
|
19
|
-
extends: [
|
|
20
|
-
'eslint:recommended',
|
|
21
|
-
'plugin:node/recommended',
|
|
22
|
-
'plugin:promise/recommended',
|
|
23
|
-
'plugin:@typescript-eslint/recommended',
|
|
24
|
-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
25
|
-
'prettier',
|
|
26
146
|
],
|
|
27
|
-
plugins: [],
|
|
28
|
-
rules: {
|
|
29
|
-
curly: 1,
|
|
30
|
-
'prefer-const': 2,
|
|
31
|
-
'require-await': 0,
|
|
32
|
-
'no-process-exit': 0,
|
|
33
|
-
'node/no-unsupported-features/es-syntax': 0,
|
|
34
|
-
'node/no-missing-import': 0,
|
|
35
|
-
'node/shebang': 0,
|
|
36
|
-
'@typescript-eslint/ban-ts-comment': 0,
|
|
37
|
-
'@typescript-eslint/no-explicit-any': 0,
|
|
38
|
-
'@typescript-eslint/no-non-null-assertion': 0,
|
|
39
|
-
'@typescript-eslint/prefer-optional-chain': 1,
|
|
40
|
-
'@typescript-eslint/require-await': 0,
|
|
41
|
-
'@typescript-eslint/no-unsafe-assignment': 0,
|
|
42
|
-
'@typescript-eslint/no-unsafe-member-access': 0,
|
|
43
|
-
'@typescript-eslint/no-unsafe-call': 0,
|
|
44
|
-
'@typescript-eslint/no-unsafe-return': 0,
|
|
45
|
-
'@typescript-eslint/no-unsafe-argument': 0,
|
|
46
|
-
},
|
|
47
147
|
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
18.
|
|
1
|
+
18.17.1
|
package/.prettierignore
CHANGED
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ To see an overview of all possible commands just run the following command witho
|
|
|
12
12
|
npx -y @raisenow/tamaro-cli
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
To see the
|
|
15
|
+
To see the information about some particular command (for example `dev` command), prepend `help` before the command name:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npx -y @raisenow/tamaro-cli help dev
|
|
@@ -44,7 +44,7 @@ Runs the local development server for _Tamaro Core_ or a particular customer con
|
|
|
44
44
|
|
|
45
45
|
### Run local server using Tamaro Core from CDN
|
|
46
46
|
|
|
47
|
-
Run the local development server for the _example-02-typical-customisations_ customer configuration. You will be able to access Tamaro on http://localhost:1234 (port may differ, see console output).
|
|
47
|
+
Run the local development server for the _example-02-typical-customisations_ customer configuration. You will be able to access Tamaro on <http://localhost:1234> (port may differ, see console output).
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
@@ -53,14 +53,14 @@ npx -y @raisenow/tamaro-cli dev
|
|
|
53
53
|
|
|
54
54
|
### Run local server using a locally running Tamaro Core
|
|
55
55
|
|
|
56
|
-
1.
|
|
56
|
+
1. Run the local development web server for _Tamaro Core_ in the first terminal tab. You will be able to access a default configuration of Tamaro on <http://localhost:1234> (port may differ, see console output).
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
cd /path/to/tamaro-core
|
|
60
60
|
npx -y @raisenow/tamaro-cli dev
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
2.
|
|
63
|
+
2. Run the local development web server for the _example-02-typical-customisations_ customer configuration in the second terminal tab. After running this command, you will able to access the configuration on <http://localhost:1235> (port may differ, see console output).
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
@@ -100,8 +100,7 @@ Build an optimised (minified) bundle of _Tamaro Core_ or a customer configuratio
|
|
|
100
100
|
- `--port <port>` – Web server port (default: 1234)
|
|
101
101
|
- `--env <env>` – Environment (dev, stage, prod)
|
|
102
102
|
- `--deploy` – Deploy _Tamaro Core_ or a customer configuration bundle to AWS S3
|
|
103
|
-
- `--tag <tag>` – Tag which should be used for the deployment of the bundle (default:
|
|
104
|
-
- `--profile <profile>` – AWS profile which should be used for the deployment of the bundle (default: “payments-prod-cs-deployer”)
|
|
103
|
+
- `--tag <tag>` – Tag which should be used for the deployment of the bundle (default: "latest")
|
|
105
104
|
|
|
106
105
|
### Build and deploy a customer configuration
|
|
107
106
|
|
|
@@ -112,7 +111,7 @@ cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
|
112
111
|
npx -y @raisenow/tamaro-cli build --deploy
|
|
113
112
|
```
|
|
114
113
|
|
|
115
|
-
As a result, the bundle should be deployed to: https://tamaro.raisenow.com/example-02-typical-customisations/latest
|
|
114
|
+
As a result, the bundle should be deployed to: <https://tamaro.raisenow.com/example-02-typical-customisations/latest/>
|
|
116
115
|
|
|
117
116
|
### Build and deploy a customer configuration with a specific tag
|
|
118
117
|
|
|
@@ -123,13 +122,13 @@ cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
|
123
122
|
npx -y @raisenow/tamaro-cli build --deploy --tag WEB-123
|
|
124
123
|
```
|
|
125
124
|
|
|
126
|
-
As a result, the bundle should be deployed to: https://tamaro.raisenow.com/example-02-typical-customisations/WEB-123
|
|
125
|
+
As a result, the bundle should be deployed to: <https://tamaro.raisenow.com/example-02-typical-customisations/WEB-123/>
|
|
127
126
|
|
|
128
127
|
### Build and serve a customer configuration
|
|
129
128
|
|
|
130
129
|
Build and serve an optimised (minified) bundle of the _example-02-typical-customisations_ customer configuration.
|
|
131
130
|
|
|
132
|
-
After running this command, a local web server should be running on http://localhost:1234 (port may differ, see console output).
|
|
131
|
+
After running this command, a local web server should be running on <http://localhost:1234> (port may differ, see console output).
|
|
133
132
|
|
|
134
133
|
```bash
|
|
135
134
|
cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
@@ -142,14 +141,14 @@ Run a local web server for pre-built bundle.
|
|
|
142
141
|
|
|
143
142
|
### Example
|
|
144
143
|
|
|
145
|
-
1.
|
|
144
|
+
1. Build an optimised (minified) bundle of the _example-02-typical-customisations_ customer configuration
|
|
146
145
|
|
|
147
146
|
```bash
|
|
148
147
|
cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
149
148
|
npx -y @raisenow/tamaro-cli build
|
|
150
149
|
```
|
|
151
150
|
|
|
152
|
-
2.
|
|
151
|
+
2. Serve it. After running this command, web-server should be running on <http://localhost:1234> (port may differ, see console output).
|
|
153
152
|
|
|
154
153
|
```bash
|
|
155
154
|
npx -y @raisenow/tamaro-cli serve
|
|
@@ -161,27 +160,26 @@ Deploy a pre-built _Tamaro Core_ or customer configuration bundle to AWS S3.
|
|
|
161
160
|
|
|
162
161
|
### Options
|
|
163
162
|
|
|
164
|
-
- `--tag <tag>` – Tag which should be used for the deployment of the bundle (default:
|
|
165
|
-
- `--profile <profile>` – AWS profile which should be used for the deployment of the bundle (default: “payments-prod-cs-deployer”)
|
|
163
|
+
- `--tag <tag>` – Tag which should be used for the deployment of the bundle (default: "latest")
|
|
166
164
|
|
|
167
165
|
Make sure you have built the bundle before deploying it with this command, otherwise you may mistakenly deploy the bundle from a previous build.
|
|
168
166
|
|
|
169
167
|
### Example
|
|
170
168
|
|
|
171
|
-
1.
|
|
169
|
+
1. Build an optimised (minified) bundle of the _example-02-typical-customisations_ customer configuration
|
|
172
170
|
|
|
173
171
|
```bash
|
|
174
172
|
cd /path/to/tamaro-configurations/configs/example-02-typical-customisations
|
|
175
173
|
npx -y @raisenow/tamaro-cli build
|
|
176
174
|
```
|
|
177
175
|
|
|
178
|
-
2.
|
|
176
|
+
2. Deploy it
|
|
179
177
|
|
|
180
178
|
```bash
|
|
181
179
|
npx -y @raisenow/tamaro-cli deploy
|
|
182
180
|
```
|
|
183
181
|
|
|
184
|
-
3.
|
|
182
|
+
3. Optionally, deploy it with the _WEB-123_ tag
|
|
185
183
|
|
|
186
184
|
```bash
|
|
187
185
|
npx -y @raisenow/tamaro-cli deploy --tag WEB-123
|
|
@@ -194,7 +192,6 @@ List deployments of _Tamaro Core_ or a particular customer configuration.
|
|
|
194
192
|
### Options
|
|
195
193
|
|
|
196
194
|
- `--config <config>` – Configuration name (default: current customer configuration)
|
|
197
|
-
- `--profile <profile>` – AWS profile which should be used for fetching deployments (default: “payments-prod-cs-deployer”)
|
|
198
195
|
|
|
199
196
|
### Example
|
|
200
197
|
|
|
@@ -207,11 +204,6 @@ npx -y @raisenow/tamaro-cli list-deployed
|
|
|
207
204
|
|
|
208
205
|
Deploy a widget’s email configuration to AWS S3.
|
|
209
206
|
|
|
210
|
-
### Options
|
|
211
|
-
|
|
212
|
-
- `--bucket <bucket>` – AWS S3 bucket where it should be deployed (default: “rnw-email-service”)
|
|
213
|
-
- `--profile <profile>` – AWS profile which should be used for the deployment of email configuration (default: “payments-prod-cs-deployer”)
|
|
214
|
-
|
|
215
207
|
### Example
|
|
216
208
|
|
|
217
209
|
```bash
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
// node_modules/tsup/assets/esm_shims.js
|
|
1
|
+
// node_modules/.pnpm/tsup@7.2.0_postcss@8.4.29_typescript@5.2.2/node_modules/tsup/assets/esm_shims.js
|
|
2
2
|
import { fileURLToPath } from "url";
|
|
3
3
|
import path from "path";
|
|
4
4
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
5
|
var getDirname = () => path.dirname(getFilename());
|
|
6
6
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
7
|
|
|
8
|
-
// src/lib/constants.ts
|
|
9
|
-
var DEFAULT_TAG = "latest";
|
|
10
|
-
var DEFAULT_PORT = 1234;
|
|
11
|
-
var DEFAULT_AWS_PROFILE = "payments-prod-cs-deployer";
|
|
12
|
-
var DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET = "rnw-email-service";
|
|
13
|
-
var AWS_S3_BUCKET = "tamaro.raisenow.com";
|
|
14
|
-
var CORE_CONFIG_NAME = "tamaro-core";
|
|
15
|
-
var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
|
|
16
|
-
var HTTPS_CRT_FILE = "localhost.crt";
|
|
17
|
-
var HTTPS_KEY_FILE = "localhost.key";
|
|
18
|
-
|
|
19
8
|
// src/lib/logging.ts
|
|
20
9
|
import chalk from "chalk";
|
|
21
|
-
import stripIndent from "strip-indent";
|
|
22
10
|
import columnify from "columnify";
|
|
11
|
+
import stripIndent from "strip-indent";
|
|
23
12
|
var logTitle = (title) => {
|
|
24
13
|
console.log(`${chalk.bold(title)}`);
|
|
25
14
|
};
|
|
@@ -38,13 +27,24 @@ var logDataTable = (data) => {
|
|
|
38
27
|
console.log("");
|
|
39
28
|
};
|
|
40
29
|
|
|
30
|
+
// src/lib/constants.ts
|
|
31
|
+
var DEFAULT_TAG = "latest";
|
|
32
|
+
var DEFAULT_PORT = 1234;
|
|
33
|
+
var AWS_S3_EMAIL_CONFIG_PROD_BUCKET = "rnw-email-service";
|
|
34
|
+
var AWS_S3_EMAIL_CONFIG_STAGE_BUCKET = "rnw-stage-email-service";
|
|
35
|
+
var AWS_S3_BUCKET = "tamaro.raisenow.com";
|
|
36
|
+
var CORE_CONFIG_NAME = "tamaro-core";
|
|
37
|
+
var AWS_CLOUDFRONT_DISTRIBUTION_ID = "EHJ1OM458YQ0I";
|
|
38
|
+
var HTTPS_CRT_FILE = "localhost.crt";
|
|
39
|
+
var HTTPS_KEY_FILE = "localhost.key";
|
|
40
|
+
|
|
41
41
|
// src/lib/resolve.ts
|
|
42
|
+
import { existsSync, realpathSync } from "fs";
|
|
42
43
|
import { createRequire } from "module";
|
|
43
44
|
import { basename, dirname, join, relative, resolve } from "path";
|
|
44
|
-
import { existsSync, realpathSync } from "fs";
|
|
45
|
-
import { getIfUtils } from "webpack-config-utils";
|
|
46
|
-
import stripIndent2 from "strip-indent";
|
|
47
45
|
import chalk2 from "chalk";
|
|
46
|
+
import stripIndent2 from "strip-indent";
|
|
47
|
+
import { getIfUtils } from "webpack-config-utils";
|
|
48
48
|
var require2 = createRequire(import.meta.url);
|
|
49
49
|
var moduleFileExtensions = ["ts", "tsx", "js", "jsx"];
|
|
50
50
|
var extensions = moduleFileExtensions.map((v) => `.${v}`);
|
|
@@ -137,13 +137,15 @@ var getIfCoreFns = () => {
|
|
|
137
137
|
// src/lib/env.ts
|
|
138
138
|
import { createRequire as createRequire2 } from "module";
|
|
139
139
|
import { basename as basename2 } from "path";
|
|
140
|
-
import glob from "glob";
|
|
141
|
-
import { expand as dotenvExpand } from "dotenv-expand";
|
|
142
140
|
import { config as dotenvConfig } from "dotenv";
|
|
141
|
+
import { expand as dotenvExpand } from "dotenv-expand";
|
|
142
|
+
import { globSync } from "glob";
|
|
143
143
|
import stripIndent3 from "strip-indent";
|
|
144
144
|
|
|
145
145
|
// src/lib/command.ts
|
|
146
|
-
import {
|
|
146
|
+
import {
|
|
147
|
+
execaCommandSync
|
|
148
|
+
} from "execa";
|
|
147
149
|
var halt = (message, exitCode = 1) => {
|
|
148
150
|
logError(message);
|
|
149
151
|
process.exit(exitCode);
|
|
@@ -159,7 +161,9 @@ var runCommandSync = (cmd, options) => {
|
|
|
159
161
|
var require3 = createRequire2(import.meta.url);
|
|
160
162
|
var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
161
163
|
const filePath = files.find((file) => basename2(file) === ".env");
|
|
162
|
-
|
|
164
|
+
if (filePath) {
|
|
165
|
+
dotenvExpand(dotenvConfig({ path: filePath }));
|
|
166
|
+
}
|
|
163
167
|
process.env.NODE_ENV ??= ifMin("production", "development");
|
|
164
168
|
process.env.BABEL_ENV ??= ifMin("production", "development");
|
|
165
169
|
process.env.EXPOSE_VAR ??= ifCore("rnw.tamaroCore", "rnw.tamaro");
|
|
@@ -168,7 +172,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
168
172
|
"rnw-tamaro"
|
|
169
173
|
);
|
|
170
174
|
process.env.WEBPACK_UNIQUE_NAME ??= ifCore("RnwTamaroCore", "RnwTamaro");
|
|
171
|
-
process.env.BUILD_DATE = new Date().toISOString();
|
|
175
|
+
process.env.BUILD_DATE = (/* @__PURE__ */ new Date()).toISOString();
|
|
172
176
|
process.env.PUBLIC_URL ??= "";
|
|
173
177
|
process.env.HMR_ENABLED ??= ifMin("false", "true");
|
|
174
178
|
if (ifCore()) {
|
|
@@ -181,7 +185,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
181
185
|
process.env.WIDGET_UUID = getWidgetUuid();
|
|
182
186
|
if (ifLocalCore()) {
|
|
183
187
|
const protocol = ifHttps() ? "https" : "http";
|
|
184
|
-
process.env.CORE_URL = `${protocol}://
|
|
188
|
+
process.env.CORE_URL = `${protocol}://localhost:1234/index.js`;
|
|
185
189
|
} else {
|
|
186
190
|
let version = process.env.CORE_VERSION;
|
|
187
191
|
version = version ? `@${version}` : "";
|
|
@@ -189,6 +193,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
const varNames = [
|
|
196
|
+
// common
|
|
192
197
|
"NODE_ENV",
|
|
193
198
|
"BABEL_ENV",
|
|
194
199
|
"EXPOSE_VAR",
|
|
@@ -196,8 +201,15 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
196
201
|
"WEBPACK_UNIQUE_NAME",
|
|
197
202
|
"BUILD_DATE",
|
|
198
203
|
"PUBLIC_URL",
|
|
204
|
+
// core
|
|
199
205
|
"PRODUCT_NAME",
|
|
200
206
|
"PRODUCT_VERSION",
|
|
207
|
+
// config
|
|
208
|
+
"WIDGET_UUID",
|
|
209
|
+
"CORE_URL",
|
|
210
|
+
"CORE_VERSION",
|
|
211
|
+
// should be explicitly specified in each config
|
|
212
|
+
// epik (obsolete since Tamaro v2.5.0)
|
|
201
213
|
"EPP_API_KEY_DEFAULT",
|
|
202
214
|
"EPP_API_URL_STAGE",
|
|
203
215
|
"EPP_API_URL_PROD",
|
|
@@ -208,12 +220,9 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
208
220
|
"EPMS_PROXY_URL_STAGE",
|
|
209
221
|
"EPMS_PROXY_URL_PROD",
|
|
210
222
|
"EPMS_TWINT_CHECKOUT_URL_STAGE",
|
|
211
|
-
"EPMS_TWINT_CHECKOUT_URL_PROD"
|
|
212
|
-
"WIDGET_UUID",
|
|
213
|
-
"CORE_URL",
|
|
214
|
-
"CORE_VERSION"
|
|
223
|
+
"EPMS_TWINT_CHECKOUT_URL_PROD"
|
|
215
224
|
];
|
|
216
|
-
const raw = Object.keys(process.env).filter((key) =>
|
|
225
|
+
const raw = Object.keys(process.env).filter((key) => key.startsWith("PUBLIC_") || varNames.includes(key)).reduce((env, key) => {
|
|
217
226
|
env[key] = process.env[key];
|
|
218
227
|
return env;
|
|
219
228
|
}, {});
|
|
@@ -228,44 +237,56 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
228
237
|
var assertEnvValid = (env) => {
|
|
229
238
|
const { ifCore } = getIfCoreFns();
|
|
230
239
|
const paths = getPaths(ifCore);
|
|
231
|
-
const files =
|
|
232
|
-
const envs = files.map((file) => basename2(file).replace(/^\.env
|
|
240
|
+
const files = globSync(paths.appEnv);
|
|
241
|
+
const envs = files.map((file) => basename2(file).replace(/^\.env\./, "")).map((file) => basename2(file).replace(/^\.env$/, "")).filter((v) => !!v);
|
|
233
242
|
if (envs.length === 0) {
|
|
234
243
|
if (env) {
|
|
235
|
-
console.log(
|
|
244
|
+
console.log('Flag "--env" is ignored.');
|
|
236
245
|
}
|
|
237
246
|
}
|
|
238
247
|
if (envs.length !== 0) {
|
|
239
248
|
if (!env) {
|
|
240
|
-
halt(
|
|
249
|
+
halt('Flag "--env" is required.');
|
|
241
250
|
}
|
|
242
|
-
if (!envs.includes(env)) {
|
|
251
|
+
if (env && !envs.includes(env)) {
|
|
243
252
|
halt(
|
|
244
253
|
stripIndent3(`
|
|
245
|
-
Flag
|
|
246
|
-
Available values are: ${envs.map((v) =>
|
|
254
|
+
Flag "--env" has wrong value.
|
|
255
|
+
Available values are: ${envs.map((v) => `"${v}"`).join(", ")}.
|
|
247
256
|
`)
|
|
248
257
|
);
|
|
249
258
|
}
|
|
250
|
-
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var applyEnv = (env) => {
|
|
262
|
+
if (!env) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const { ifCore } = getIfCoreFns();
|
|
266
|
+
const paths = getPaths(ifCore);
|
|
267
|
+
const files = globSync(paths.appEnv);
|
|
268
|
+
const filePath = files.find((file) => basename2(file) === `.env.${env}`);
|
|
269
|
+
if (filePath) {
|
|
251
270
|
dotenvExpand(dotenvConfig({ path: filePath }));
|
|
252
271
|
}
|
|
253
272
|
};
|
|
254
273
|
|
|
255
274
|
export {
|
|
275
|
+
logTitle,
|
|
276
|
+
logError,
|
|
277
|
+
logCommand,
|
|
278
|
+
logDataTable,
|
|
279
|
+
halt,
|
|
280
|
+
runCommandSync,
|
|
256
281
|
DEFAULT_TAG,
|
|
257
282
|
DEFAULT_PORT,
|
|
258
|
-
|
|
259
|
-
|
|
283
|
+
AWS_S3_EMAIL_CONFIG_PROD_BUCKET,
|
|
284
|
+
AWS_S3_EMAIL_CONFIG_STAGE_BUCKET,
|
|
260
285
|
AWS_S3_BUCKET,
|
|
261
286
|
CORE_CONFIG_NAME,
|
|
262
287
|
AWS_CLOUDFRONT_DISTRIBUTION_ID,
|
|
263
288
|
HTTPS_CRT_FILE,
|
|
264
289
|
HTTPS_KEY_FILE,
|
|
265
|
-
logTitle,
|
|
266
|
-
logError,
|
|
267
|
-
logCommand,
|
|
268
|
-
logDataTable,
|
|
269
290
|
moduleFileExtensions,
|
|
270
291
|
extensions,
|
|
271
292
|
resolveApp,
|
|
@@ -275,8 +296,7 @@ export {
|
|
|
275
296
|
getPaths,
|
|
276
297
|
getRelativePaths,
|
|
277
298
|
getIfCoreFns,
|
|
278
|
-
halt,
|
|
279
|
-
runCommandSync,
|
|
280
299
|
getEnvVars,
|
|
281
|
-
assertEnvValid
|
|
300
|
+
assertEnvValid,
|
|
301
|
+
applyEnv
|
|
282
302
|
};
|