@raisenow/tamaro-cli 1.0.19 → 1.0.22

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/.nvmrc CHANGED
@@ -1 +1 @@
1
- 16.15.0
1
+ 16.17.0
package/README.md CHANGED
@@ -38,6 +38,7 @@ Runs the local development server for _Tamaro Core_ or a particular customer con
38
38
  ### Options
39
39
 
40
40
  - `--local-core` – Load _Tamaro Core_ from localhost:1234 instead of the CDN
41
+ - `--https` – Let local web server serve Tamaro with SSL encryption
41
42
  - `--port <port>` – Web server port (default: 1234)
42
43
  - `--env <env>` – Environment (dev, stage, prod)
43
44
 
@@ -66,6 +67,26 @@ npx -y @raisenow/tamaro-cli dev
66
67
  npx -y @raisenow/tamaro-cli dev --local-core
67
68
  ```
68
69
 
70
+ ### Use Transport Level Security (HTTPS)
71
+
72
+ You might want to the local web server to serve Tamaro over HTTPS, for example for testing wallet payments over Google Pay. For that, you have to install [mkcert](https://mkcert.org/), then generate a local certificate and key file and install it into your local trust stores using this command in the root directory of the Tamaro configuration repository (or Tamaro Core):
73
+
74
+ Install `mkcert`:
75
+
76
+ ```bash
77
+ brew install mkcert
78
+ ```
79
+
80
+ Generate certificate:
81
+
82
+ ```bash
83
+ mkcert -install -cert-file localhost.crt -key-file localhost.key localhost 127.0.0.1 0.0.0.0 ::1
84
+ ```
85
+
86
+ You will see that the certificate and key files are created. Keep them for yourself. Do not share them or commit them. (They should be ignored by Git.)
87
+
88
+ You can then use the flag `--https` with the CLI. If you are using the local Tamaro Core, you also have to serve that over HTTPS. Certificate and key files must be copied to Tamaro Core folder as well.
89
+
69
90
  ## `build`
70
91
 
71
92
  Build an optimised (minified) bundle of _Tamaro Core_ or a customer configuration.
@@ -75,6 +96,7 @@ Build an optimised (minified) bundle of _Tamaro Core_ or a customer configuratio
75
96
  - `--local-core` – Load _Tamaro Core_ from localhost:1234 instead of the CDN
76
97
  - `--analyze` – Generate bundle statistics to `reports` folder
77
98
  - `--serve` – Run the generated bundle with a local web server
99
+ - `--https` – Let local web server serve Tamaro with SSL encryption
78
100
  - `--port <port>` – Web server port (default: 1234)
79
101
  - `--env <env>` – Environment (dev, stage, prod)
80
102
  - `--deploy` – Deploy _Tamaro Core_ or a customer configuration bundle to AWS S3
@@ -5,6 +5,17 @@ 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
+
8
19
  // src/lib/logging.ts
9
20
  import chalk from "chalk";
10
21
  import stripIndent from "strip-indent";
@@ -43,7 +54,9 @@ var TAMARO_SELF_SERVICE_PACKAGE_NAMES = ["@raisenow/tamaro-self-service"];
43
54
  var resolveApp = (relativePath) => resolve(realpathSync(process.cwd()), relativePath);
44
55
  var resolveOwn = (relativePath) => resolve(__dirname, "..", relativePath);
45
56
  var resolveModule = (resolveFn, filePath) => {
46
- const extension = moduleFileExtensions.find((extension2) => existsSync(resolveFn(`${filePath}.${extension2}`)));
57
+ const extension = moduleFileExtensions.find(
58
+ (extension2) => existsSync(resolveFn(`${filePath}.${extension2}`))
59
+ );
47
60
  if (extension) {
48
61
  return resolveFn(`${filePath}.${extension}`);
49
62
  }
@@ -58,25 +71,30 @@ var resolveBin = (name) => {
58
71
  };
59
72
  var getWidgetUuid = () => basename(resolveApp("."));
60
73
  var getPaths = (ifCore) => {
61
- return ifCore({
62
- app: resolveApp("."),
63
- appEntry: resolveModule(resolveApp, "src/index"),
64
- appDist: resolveApp("dist"),
65
- appNodeModules: resolveApp("node_modules"),
66
- appTsConfig: resolveApp("tsconfig.json"),
67
- appHtml: resolveApp("src/*.html"),
68
- appEnv: resolveApp(".env*"),
69
- appTailwindConfig: resolveApp("tailwind.config.js")
70
- }, {
71
- app: resolveApp("."),
72
- appEntry: resolveModule(resolveApp, "widget"),
73
- appDist: resolveApp(`../../dist/${getWidgetUuid()}`),
74
- appNodeModules: resolveApp("../../node_modules"),
75
- appTsConfig: resolveApp("tsconfig.json"),
76
- appHtml: resolveApp("*.html"),
77
- appEnv: resolveApp(".env*"),
78
- appTailwindConfig: void 0
79
- });
74
+ return ifCore(
75
+ {
76
+ root: resolveApp("."),
77
+ app: resolveApp("."),
78
+ appEntry: resolveModule(resolveApp, "src/index"),
79
+ appDist: resolveApp("dist"),
80
+ appNodeModules: resolveApp("node_modules"),
81
+ appTsConfig: resolveApp("tsconfig.json"),
82
+ appHtml: resolveApp("src/*.html"),
83
+ appEnv: resolveApp(".env*"),
84
+ appTailwindConfig: resolveApp("tailwind.config.js")
85
+ },
86
+ {
87
+ root: resolveApp("../.."),
88
+ app: resolveApp("."),
89
+ appEntry: resolveModule(resolveApp, "widget"),
90
+ appDist: resolveApp(`../../dist/${getWidgetUuid()}`),
91
+ appNodeModules: resolveApp("../../node_modules"),
92
+ appTsConfig: resolveApp("tsconfig.json"),
93
+ appHtml: resolveApp("*.html"),
94
+ appEnv: resolveApp(".env*"),
95
+ appTailwindConfig: void 0
96
+ }
97
+ );
80
98
  };
81
99
  var getRelativePaths = (paths) => {
82
100
  const relativePaths = {};
@@ -101,12 +119,18 @@ var getIfCoreFns = () => {
101
119
  "core"
102
120
  ]);
103
121
  }
104
- logError(stripIndent2(` You must run "npx @raisenow/tamaro-cli" commands from:
122
+ logError(
123
+ stripIndent2(` You must run "npx @raisenow/tamaro-cli" commands from:
105
124
  1. Root of "${chalk2.bold(TAMARO_CORE_PACKAGE_NAMES[0])}" package folder.
106
- 2. Root of particular customer configuration folder of "${chalk2.bold(TAMARO_CONFIGURATIONS_PACKAGE_NAMES[0])}" package.
107
- 3. "src/self-service" folder of "${chalk2.bold(TAMARO_SELF_SERVICE_PACKAGE_NAMES[0])}" package.
125
+ 2. Root of particular customer configuration folder of "${chalk2.bold(
126
+ TAMARO_CONFIGURATIONS_PACKAGE_NAMES[0]
127
+ )}" package.
128
+ 3. "src/self-service" folder of "${chalk2.bold(
129
+ TAMARO_SELF_SERVICE_PACKAGE_NAMES[0]
130
+ )}" package.
108
131
  You are currently in "${chalk2.bold(realpathSync(process.cwd()))}".
109
- `));
132
+ `)
133
+ );
110
134
  process.exit(1);
111
135
  };
112
136
 
@@ -133,14 +157,17 @@ var runCommandSync = (cmd, options) => {
133
157
 
134
158
  // src/lib/env.ts
135
159
  var require3 = createRequire2(import.meta.url);
136
- var getEnvVars = (files, ifMin, ifCore, ifLocalCore) => {
160
+ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
137
161
  var _a, _b, _c, _d, _e, _f, _g, _h;
138
162
  const filePath = files.find((file) => basename2(file) === ".env");
139
163
  dotenvExpand(dotenvConfig({ path: filePath }));
140
164
  (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = ifMin("production", "development"));
141
165
  (_b = process.env).BABEL_ENV ?? (_b.BABEL_ENV = ifMin("production", "development"));
142
166
  (_c = process.env).EXPOSE_VAR ?? (_c.EXPOSE_VAR = ifCore("rnw.tamaroCore", "rnw.tamaro"));
143
- (_d = process.env).ELEMENT_ATTRIBUTE_DATA_WIDGET ?? (_d.ELEMENT_ATTRIBUTE_DATA_WIDGET = ifCore("rnw-tamaro-core", "rnw-tamaro"));
167
+ (_d = process.env).ELEMENT_ATTRIBUTE_DATA_WIDGET ?? (_d.ELEMENT_ATTRIBUTE_DATA_WIDGET = ifCore(
168
+ "rnw-tamaro-core",
169
+ "rnw-tamaro"
170
+ ));
144
171
  (_e = process.env).WEBPACK_UNIQUE_NAME ?? (_e.WEBPACK_UNIQUE_NAME = ifCore("RnwTamaroCore", "RnwTamaro"));
145
172
  process.env.BUILD_DATE = new Date().toISOString();
146
173
  (_f = process.env).PUBLIC_URL ?? (_f.PUBLIC_URL = "");
@@ -154,7 +181,8 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore) => {
154
181
  if (!ifCore()) {
155
182
  process.env.WIDGET_UUID = getWidgetUuid();
156
183
  if (ifLocalCore()) {
157
- process.env.CORE_URL = `http://0.0.0.0:1234/index.js`;
184
+ const protocol = ifHttps() ? "https" : "http";
185
+ process.env.CORE_URL = `${protocol}://0.0.0.0:1234/index.js`;
158
186
  } else {
159
187
  let version = process.env.CORE_VERSION;
160
188
  version = version ? `@${version}` : "";
@@ -171,10 +199,18 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore) => {
171
199
  "PUBLIC_URL",
172
200
  "PRODUCT_NAME",
173
201
  "PRODUCT_VERSION",
202
+ "EPP_API_KEY_DEFAULT",
203
+ "EPP_API_URL_STAGE",
204
+ "EPP_API_URL_PROD",
205
+ "EPMS_API_URL_STAGE",
206
+ "EPMS_API_URL_PROD",
207
+ "EPP_PROXY_URL_STAGE",
208
+ "EPP_PROXY_URL_PROD",
209
+ "EPMS_PROXY_URL_STAGE",
210
+ "EPMS_PROXY_URL_PROD",
174
211
  "WIDGET_UUID",
175
212
  "CORE_URL",
176
- "CORE_VERSION",
177
- "IS_CREDIT_CARD_IFRAME"
213
+ "CORE_VERSION"
178
214
  ];
179
215
  const raw = Object.keys(process.env).filter((key) => /^PUBLIC_/.test(key) || varNames.includes(key)).reduce((env, key) => {
180
216
  env[key] = process.env[key];
@@ -203,10 +239,12 @@ var assertEnvValid = (env) => {
203
239
  halt("Flag \u201C--env\u201D is required.");
204
240
  }
205
241
  if (!envs.includes(env)) {
206
- halt(stripIndent3(`
242
+ halt(
243
+ stripIndent3(`
207
244
  Flag \u201C--env\u201D has wrong value.
208
245
  Available values are: ${envs.map((v) => `\u201C${v}\u201D`).join(", ")}.
209
- `));
246
+ `)
247
+ );
210
248
  }
211
249
  const filePath = files.find((file) => basename2(file) === `.env.${env}`);
212
250
  dotenvExpand(dotenvConfig({ path: filePath }));
@@ -214,6 +252,15 @@ var assertEnvValid = (env) => {
214
252
  };
215
253
 
216
254
  export {
255
+ DEFAULT_TAG,
256
+ DEFAULT_PORT,
257
+ DEFAULT_AWS_PROFILE,
258
+ DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET,
259
+ AWS_S3_BUCKET,
260
+ CORE_CONFIG_NAME,
261
+ AWS_CLOUDFRONT_DISTRIBUTION_ID,
262
+ HTTPS_CRT_FILE,
263
+ HTTPS_KEY_FILE,
217
264
  logTitle,
218
265
  logError,
219
266
  logCommand,