@raisenow/tamaro-cli 1.0.12 → 1.0.15

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.
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  __spreadValues,
3
3
  extensions,
4
+ getEnvVars,
4
5
  getIfCoreFns,
5
6
  getPaths,
6
7
  getRelativePaths,
7
- getWidgetUuid,
8
8
  logDataTable,
9
9
  logTitle,
10
10
  moduleFileExtensions,
11
11
  resolveApp
12
- } from "./chunk-PIEFLCDU.js";
12
+ } from "./chunk-BWJBN44Y.js";
13
13
 
14
14
  // src/webpack.config.ts
15
- import { createRequire as createRequire2 } from "module";
15
+ import { createRequire } from "module";
16
16
  import { basename, dirname } from "path";
17
17
  import { existsSync } from "fs";
18
18
  import glob from "glob";
@@ -42,7 +42,10 @@ var InterpolateHtmlPlugin = class {
42
42
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
43
43
  const hooks = HtmlWebpackPlugin.getHooks(compilation);
44
44
  hooks.alterAssetTagGroups.tap(PLUGIN_NAME, (assets) => {
45
- this.replacements["ENTRY"] = assets.headTags[0].attributes["src"];
45
+ var _a;
46
+ const publicUrl = (_a = this.replacements["PUBLIC_URL"]) != null ? _a : "";
47
+ const entry = assets.headTags[0].attributes["src"];
48
+ this.replacements["ENTRY"] = `${publicUrl}${entry}`;
46
49
  return assets;
47
50
  });
48
51
  hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
@@ -55,64 +58,8 @@ var InterpolateHtmlPlugin = class {
55
58
  }
56
59
  };
57
60
 
58
- // src/lib/env.ts
59
- import { createRequire } from "module";
60
- import { expand as dotenvExpand } from "dotenv-expand";
61
- import { config as dotenvConfig } from "dotenv";
62
- var require2 = createRequire(import.meta.url);
63
- var getEnvVars = (filePath, ifMin, ifCore, ifLocalCore) => {
64
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
65
- dotenvExpand(dotenvConfig({ path: filePath }));
66
- (_b = (_a = process.env).NODE_ENV) != null ? _b : _a.NODE_ENV = ifMin("production", "development");
67
- (_d = (_c = process.env).BABEL_ENV) != null ? _d : _c.BABEL_ENV = ifMin("production", "development");
68
- (_f = (_e = process.env).EXPOSE_VAR) != null ? _f : _e.EXPOSE_VAR = ifCore("rnw.tamaroCore", "rnw.tamaro");
69
- (_h = (_g = process.env).ELEMENT_ATTRIBUTE_DATA_WIDGET) != null ? _h : _g.ELEMENT_ATTRIBUTE_DATA_WIDGET = ifCore("rnw-tamaro-core", "rnw-tamaro");
70
- (_j = (_i = process.env).WEBPACK_UNIQUE_NAME) != null ? _j : _i.WEBPACK_UNIQUE_NAME = ifCore("RnwTamaroCore", "RnwTamaro");
71
- (_l = (_k = process.env).HMR_ENABLED) != null ? _l : _k.HMR_ENABLED = ifMin("false", "true");
72
- if (ifCore()) {
73
- process.env.PRODUCT_NAME = "tamaro";
74
- const corePkgPath = resolveApp("package.json");
75
- const { version } = require2(corePkgPath);
76
- process.env.PRODUCT_VERSION = version;
77
- }
78
- if (!ifCore()) {
79
- process.env.WIDGET_UUID = getWidgetUuid();
80
- if (ifLocalCore()) {
81
- process.env.CORE_URL = `http://0.0.0.0:1234/index.js`;
82
- } else {
83
- let version = process.env.CORE_VERSION;
84
- version = version ? `@${version}` : "";
85
- (_n = (_m = process.env).CORE_URL) != null ? _n : _m.CORE_URL = `https://cdn.jsdelivr.net/npm/@raisenow/tamaro-core${version}/dist/index.js`;
86
- }
87
- }
88
- const varNames = [
89
- "NODE_ENV",
90
- "BABEL_ENV",
91
- "EXPOSE_VAR",
92
- "ELEMENT_ATTRIBUTE_DATA_WIDGET",
93
- "WEBPACK_UNIQUE_NAME",
94
- "PRODUCT_NAME",
95
- "PRODUCT_VERSION",
96
- "WIDGET_UUID",
97
- "CORE_URL",
98
- "CORE_VERSION",
99
- "IS_CREDIT_CARD_IFRAME"
100
- ];
101
- const raw = Object.keys(process.env).filter((key) => /^PUBLIC_/.test(key) || varNames.includes(key)).reduce((env, key) => {
102
- env[key] = process.env[key];
103
- return env;
104
- }, {});
105
- const stringified = {
106
- "process.env": Object.keys(raw).reduce((env, key) => {
107
- env[key] = JSON.stringify(raw[key]);
108
- return env;
109
- }, {})
110
- };
111
- return { raw, stringified };
112
- };
113
-
114
61
  // src/webpack.config.ts
115
- var require3 = createRequire2(import.meta.url);
62
+ var require2 = createRequire(import.meta.url);
116
63
  var imageInlineSizeLimit = 0;
117
64
  var getWebpackConfig = async (env) => {
118
65
  const { ifMin, ifNotMin } = getIfUtils(env, ["min"]);
@@ -121,7 +68,8 @@ var getWebpackConfig = async (env) => {
121
68
  const { ifCore } = getIfCoreFns();
122
69
  const paths = getPaths(ifCore);
123
70
  const appHtmlFiles = glob.sync(paths.appHtml);
124
- const envVars = getEnvVars(paths.appEnv, ifMin, ifCore, ifLocalCore);
71
+ const appEnvFiles = glob.sync(paths.appEnv);
72
+ const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore);
125
73
  const { ifHmr } = getIfUtils({ hmr: process.env.HMR_ENABLED === "true" }, ["hmr"]);
126
74
  const useTailwind = ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig);
127
75
  logTitle("Paths:");
@@ -132,7 +80,7 @@ var getWebpackConfig = async (env) => {
132
80
  return removeEmpty([
133
81
  ifMin({ loader: MiniCssExtractPlugin.loader }),
134
82
  ifNotMin({
135
- loader: require3.resolve("style-loader"),
83
+ loader: require2.resolve("style-loader"),
136
84
  options: {
137
85
  attributes: {
138
86
  "data-widget": process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET
@@ -140,35 +88,35 @@ var getWebpackConfig = async (env) => {
140
88
  }
141
89
  }),
142
90
  {
143
- loader: require3.resolve("css-loader"),
91
+ loader: require2.resolve("css-loader"),
144
92
  options: __spreadValues({
145
93
  sourceMap: ifNotMin(),
146
94
  importLoaders: 3
147
95
  }, cssOptions)
148
96
  },
149
97
  {
150
- loader: require3.resolve("postcss-loader"),
98
+ loader: require2.resolve("postcss-loader"),
151
99
  options: {
152
100
  postcssOptions: {
153
101
  plugins: removeEmpty([
154
102
  useTailwind ? [
155
- require3.resolve("tailwindcss", {
103
+ require2.resolve("tailwindcss", {
156
104
  paths: [paths.appNodeModules]
157
105
  }),
158
106
  paths.appTailwindConfig
159
107
  ] : void 0,
160
- require3.resolve("postcss-custom-properties"),
161
- require3.resolve("autoprefixer")
108
+ require2.resolve("postcss-custom-properties"),
109
+ require2.resolve("autoprefixer")
162
110
  ])
163
111
  }
164
112
  }
165
113
  },
166
114
  {
167
- loader: require3.resolve("resolve-url-loader"),
115
+ loader: require2.resolve("resolve-url-loader"),
168
116
  options: { sourceMap: ifNotMin() }
169
117
  },
170
118
  {
171
- loader: require3.resolve("sass-loader"),
119
+ loader: require2.resolve("sass-loader"),
172
120
  options: { sourceMap: true }
173
121
  }
174
122
  ]);
@@ -213,7 +161,7 @@ var getWebpackConfig = async (env) => {
213
161
  enforce: "pre",
214
162
  exclude: /@babel\/runtime/,
215
163
  test: /\.(js|jsx|ts|tsx|css|scss)$/,
216
- use: require3.resolve("source-map-loader")
164
+ use: require2.resolve("source-map-loader")
217
165
  }),
218
166
  {
219
167
  oneOf: [
@@ -224,42 +172,42 @@ var getWebpackConfig = async (env) => {
224
172
  resolveApp("node_modules/micromark"),
225
173
  resolveApp("node_modules/decode-named-character-reference")
226
174
  ], [resolveApp("."), resolveApp("../../src")]),
227
- loader: require3.resolve("babel-loader"),
175
+ loader: require2.resolve("babel-loader"),
228
176
  options: {
229
177
  babelrc: false,
230
178
  configFile: false,
231
179
  sourceMaps: ifNotMin(),
232
180
  inputSourceMap: ifNotMin(),
233
181
  presets: [
234
- require3.resolve("@babel/preset-env"),
182
+ require2.resolve("@babel/preset-env"),
235
183
  [
236
- require3.resolve("@babel/preset-typescript"),
184
+ require2.resolve("@babel/preset-typescript"),
237
185
  {
238
186
  allowDeclareFields: true
239
187
  }
240
188
  ],
241
- require3.resolve("@babel/preset-react")
189
+ require2.resolve("@babel/preset-react")
242
190
  ],
243
191
  plugins: removeEmpty([
244
192
  [
245
- require3.resolve("@babel/plugin-transform-runtime"),
193
+ require2.resolve("@babel/plugin-transform-runtime"),
246
194
  {
247
195
  corejs: {
248
196
  version: 3,
249
197
  proposals: true
250
198
  },
251
- absoluteRuntime: dirname(require3.resolve("@babel/runtime-corejs3/package.json"))
199
+ absoluteRuntime: dirname(require2.resolve("@babel/runtime-corejs3/package.json"))
252
200
  }
253
201
  ],
254
202
  [
255
- require3.resolve("@babel/plugin-proposal-decorators"),
203
+ require2.resolve("@babel/plugin-proposal-decorators"),
256
204
  {
257
205
  legacy: true
258
206
  }
259
207
  ],
260
- require3.resolve("@babel/plugin-syntax-dynamic-import"),
261
- require3.resolve("babel-plugin-lodash"),
262
- ifHmr(require3.resolve("react-refresh/babel"))
208
+ require2.resolve("@babel/plugin-syntax-dynamic-import"),
209
+ require2.resolve("babel-plugin-lodash"),
210
+ ifHmr(require2.resolve("react-refresh/babel"))
263
211
  ])
264
212
  }
265
213
  },
@@ -280,8 +228,7 @@ var getWebpackConfig = async (env) => {
280
228
  })
281
229
  },
282
230
  {
283
- test: /\.svg$/,
284
- issuer: [/\.html$/, /\.s?css$/],
231
+ test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
285
232
  type: "asset",
286
233
  parser: {
287
234
  dataUrlCondition: {
@@ -290,54 +237,18 @@ var getWebpackConfig = async (env) => {
290
237
  }
291
238
  },
292
239
  {
293
- test: /\.svg$/,
294
- issuer: [/\.(ts|tsx|js|jsx|md|mdx)$/],
240
+ test: /\.ya?ml$/,
295
241
  use: [
242
+ { loader: require2.resolve("json-loader") },
296
243
  {
297
- loader: require3.resolve("@svgr/webpack"),
298
- options: {
299
- svgoConfig: {
300
- plugins: [
301
- {
302
- removeHiddenElems: false,
303
- moveGroupAttrsToElems: false,
304
- collapseGroups: false
305
- }
306
- ]
307
- },
308
- prettier: false,
309
- titleProp: true,
310
- ref: true
311
- }
312
- },
313
- {
314
- loader: require3.resolve("url-loader"),
315
- options: {
316
- name: "assets/[name]-[contenthash:16].[ext]",
317
- limit: imageInlineSizeLimit
318
- }
244
+ loader: require2.resolve("yaml-loader"),
245
+ options: { asJSON: true }
319
246
  }
320
247
  ]
321
248
  },
322
- {
323
- test: /\.(png|jpe?g|webp|gif|ico|ttf|eot|woff2?)$/,
324
- type: "asset",
325
- parser: {
326
- dataUrlCondition: {
327
- maxSize: imageInlineSizeLimit
328
- }
329
- }
330
- },
331
- {
332
- test: /\.ya?ml$/,
333
- use: [
334
- { loader: require3.resolve("json-loader") },
335
- { loader: require3.resolve("yaml-loader") }
336
- ]
337
- },
338
249
  {
339
250
  test: /\.html$/,
340
- loader: require3.resolve("html-loader"),
251
+ loader: require2.resolve("html-loader"),
341
252
  options: {
342
253
  minimize: false
343
254
  }
@@ -375,7 +286,7 @@ var getWebpackConfig = async (env) => {
375
286
  new webpack.ProgressPlugin(),
376
287
  new ESLintPlugin({
377
288
  extensions: moduleFileExtensions,
378
- eslintPath: require3.resolve("eslint"),
289
+ eslintPath: require2.resolve("eslint"),
379
290
  cwd: paths.app,
380
291
  resolvePluginsRelativeTo: paths.app
381
292
  }),
@@ -390,7 +301,7 @@ var getWebpackConfig = async (env) => {
390
301
  new webpack.DefinePlugin(envVars.stringified),
391
302
  new ForkTsCheckerWebpackPlugin({
392
303
  typescript: {
393
- typescriptPath: require3.resolve("typescript", {
304
+ typescriptPath: require2.resolve("typescript", {
394
305
  paths: [paths.appNodeModules]
395
306
  }),
396
307
  configFile: paths.appTsConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raisenow/tamaro-cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.15",
4
4
  "author": {
5
5
  "name": "RaiseNow",
6
6
  "email": "development@raisenow.com"
@@ -21,48 +21,47 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@babel/cli": "^7.17.6",
24
- "@babel/core": "^7.17.8",
25
- "@babel/plugin-proposal-decorators": "^7.17.8",
24
+ "@babel/core": "^7.17.9",
25
+ "@babel/plugin-proposal-decorators": "^7.17.9",
26
26
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
27
27
  "@babel/plugin-transform-runtime": "^7.17.0",
28
28
  "@babel/preset-env": "^7.16.11",
29
29
  "@babel/preset-react": "^7.16.7",
30
30
  "@babel/preset-typescript": "^7.16.7",
31
- "@babel/runtime-corejs3": "^7.17.8",
32
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
31
+ "@babel/runtime-corejs3": "^7.17.9",
32
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
33
33
  "@statoscope/webpack-plugin": "^5.20.1",
34
- "@svgr/webpack": "^6.2.1",
35
34
  "@types/columnify": "^1.5.1",
36
- "@types/lodash": "^4.14.180",
37
- "@types/node": "^17.0.21",
35
+ "@types/lodash": "^4.14.182",
36
+ "@types/node": "^17.0.26",
38
37
  "@types/node-notifier": "^8.0.2",
39
38
  "@types/resolve-bin": "^0.4.1",
40
39
  "@types/webpack-config-utils": "^2.3.1",
41
- "@typescript-eslint/eslint-plugin": "^5.15.0",
42
- "@typescript-eslint/parser": "^5.15.0",
43
- "autoprefixer": "^10.4.4",
44
- "babel-loader": "^8.2.3",
40
+ "@typescript-eslint/eslint-plugin": "^5.20.0",
41
+ "@typescript-eslint/parser": "^5.20.0",
42
+ "autoprefixer": "^10.4.5",
43
+ "babel-loader": "^8.2.5",
45
44
  "babel-plugin-lodash": "^3.3.4",
46
45
  "chalk": "^5.0.1",
47
46
  "clean-webpack-plugin": "^4.0.0",
48
47
  "columnify": "^1.6.0",
49
- "commander": "^9.1.0",
48
+ "commander": "^9.2.0",
50
49
  "copy-webpack-plugin": "^10.2.4",
51
- "core-js": "^3.21.1",
50
+ "core-js": "^3.22.2",
52
51
  "css-loader": "^6.7.1",
53
52
  "css-minimizer-webpack-plugin": "^3.4.1",
54
53
  "dotenv": "^16.0.0",
55
54
  "dotenv-expand": "^8.0.3",
56
55
  "escape-string-regexp": "^5.0.0",
57
- "eslint": "^8.11.0",
56
+ "eslint": "^8.14.0",
58
57
  "eslint-config-prettier": "^8.5.0",
59
58
  "eslint-plugin-node": "^11.1.0",
60
59
  "eslint-plugin-promise": "^6.0.0",
61
60
  "eslint-webpack-plugin": "^3.1.1",
62
61
  "execa": "^6.1.0",
63
62
  "file-loader": "^6.2.0",
64
- "fork-ts-checker-webpack-plugin": "^7.2.1",
65
- "glob": "^7.2.0",
63
+ "fork-ts-checker-webpack-plugin": "^7.2.7",
64
+ "glob": "^8.0.1",
66
65
  "html-loader": "^3.1.0",
67
66
  "html-webpack-plugin": "^5.5.0",
68
67
  "json-loader": "^0.5.7",
@@ -71,24 +70,24 @@
71
70
  "node-notifier": "^10.0.1",
72
71
  "portfinder": "^1.0.28",
73
72
  "postcss": "^8.4.12",
74
- "postcss-custom-properties": "^12.1.5",
73
+ "postcss-custom-properties": "^12.1.7",
75
74
  "postcss-loader": "^6.2.1",
76
- "prettier": "^2.6.0",
77
- "react-refresh": "^0.11.0",
75
+ "prettier": "^2.6.2",
76
+ "react-refresh": "^0.12.0",
78
77
  "resolve-url-loader": "^5.0.0",
79
- "sass": "^1.49.9",
78
+ "sass": "^1.50.1",
80
79
  "sass-loader": "^12.6.0",
81
80
  "source-map-loader": "^3.0.1",
82
81
  "strip-indent": "^4.0.0",
83
82
  "style-loader": "^3.3.1",
84
83
  "tsconfig-paths-webpack-plugin": "^3.5.2",
85
- "tsup": "^5.12.1",
86
- "typescript": "^4.6.2",
84
+ "tsup": "^5.12.6",
85
+ "typescript": "^4.6.3",
87
86
  "url-loader": "^4.1.1",
88
- "webpack": "^5.70.0",
87
+ "webpack": "^5.72.0",
89
88
  "webpack-cli": "^4.9.2",
90
89
  "webpack-config-utils": "^2.3.1",
91
- "webpack-dev-server": "^4.7.4",
92
- "yaml-loader": "^0.6.0"
90
+ "webpack-dev-server": "^4.8.1",
91
+ "yaml-loader": "^0.7.0"
93
92
  }
94
93
  }
package/src/cli.ts CHANGED
@@ -50,6 +50,7 @@ cli
50
50
  false,
51
51
  )
52
52
  .option('--port <port>', 'Web server port', `${DEFAULT_PORT}`)
53
+ .option('--env <env>', 'Environment (dev, stage, prod)')
53
54
  .action(async (options: DevOptions) => {
54
55
  await dev(options)
55
56
  })
@@ -67,6 +68,7 @@ cli
67
68
  .option('--analyze', 'Generate bundle statistics to "reports" folder', false)
68
69
  .option('--serve', 'Run the generated bundle with a local web server', false)
69
70
  .option('--port <port>', 'Web server port', `${DEFAULT_PORT}`)
71
+ .option('--env <env>', 'Environment (dev, stage, prod)')
70
72
  .option(
71
73
  '--deploy',
72
74
  'Deploy Tamaro Core or a customer configuration bundle to AWS S3',
@@ -7,9 +7,10 @@ import {
7
7
  resolveBin,
8
8
  resolveOwn,
9
9
  } from 'lib/resolve'
10
+ import {assertEnvValid} from 'lib/env'
10
11
  import {logCommand, logTitle} from 'lib/logging'
11
12
  import {notify} from 'lib/notifier'
12
- import {fail, runCommandSync} from 'lib/command'
13
+ import {halt, runCommandSync} from 'lib/command'
13
14
  import {DeployOptions} from 'commands/deploy'
14
15
 
15
16
  ///////////////////////////////////////////////////////////////////////////////
@@ -19,6 +20,7 @@ export type BuildOptions = {
19
20
  analyze: boolean
20
21
  serve: boolean
21
22
  deploy: boolean
23
+ env: string
22
24
  }
23
25
 
24
26
  ///////////////////////////////////////////////////////////////////////////////
@@ -68,18 +70,19 @@ export const build = async (
68
70
  ///////////////////////////////////////////////////////////////////////////////
69
71
 
70
72
  const assertOptionsValid = (options: BuildOptions & DeployOptions) => {
71
- const {localCore, deploy, profile} = options
73
+ const {localCore, deploy, profile, env} = options
72
74
  const {ifCore} = getIfCoreFns()
73
75
 
74
76
  if (ifCore() && localCore) {
75
- fail('Flag "--local-core" is redundant if running in Tamaro Core context.')
77
+ halt('Flag “--local-core is redundant if running in Tamaro Core context.')
76
78
  }
77
79
 
78
80
  if (localCore && deploy) {
79
- fail('Flags "--local-core" and "--deploy" must not be used together.')
81
+ halt('Flags “--local-core and “--deploy must not be used together.')
80
82
  }
81
83
 
82
84
  assertProfileValid(profile)
85
+ assertEnvValid(env)
83
86
  }
84
87
 
85
88
  ///////////////////////////////////////////////////////////////////////////////
@@ -8,7 +8,7 @@ import {
8
8
  import {logCommand, logDataTable, logTitle} from 'lib/logging'
9
9
  import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
10
10
  import {notify} from 'lib/notifier'
11
- import {fail, runCommandSync} from 'lib/command'
11
+ import {halt, runCommandSync} from 'lib/command'
12
12
 
13
13
  ///////////////////////////////////////////////////////////////////////////////
14
14
 
@@ -26,8 +26,8 @@ export const deployEmailConfig = async (
26
26
  const emailConfigPath = `${paths.app}/email-config`
27
27
 
28
28
  assertOptionsValid(options)
29
- assertEmailConfigPathExists(emailConfigPath)
30
29
  assertIsNotCore()
30
+ assertEmailConfigPathExists(emailConfigPath)
31
31
 
32
32
  const flags = prepareFlags([], options).join(' ')
33
33
  const {bucket} = options
@@ -48,7 +48,7 @@ export const deployEmailConfig = async (
48
48
  try {
49
49
  withAwsAuthenticate(() => runCommandSync(cmd, {stdout: 'inherit'}), options)
50
50
  } catch (error: any) {
51
- fail(error.stderr)
51
+ halt(error.stderr)
52
52
  }
53
53
 
54
54
  /////////////////////////////////////////////////////////////////////////////
@@ -81,7 +81,7 @@ const assertOptionsValid = (options: DeployEmailConfigOptions) => {
81
81
 
82
82
  const assertEmailConfigPathExists = (distPath: string) => {
83
83
  if (!existsSync(distPath)) {
84
- fail('Email config folder does not exists. Nothing to deploy.')
84
+ halt('Email config folder does not exists. Nothing to deploy.', 0)
85
85
  }
86
86
  }
87
87
 
@@ -91,7 +91,7 @@ const assertBucketValid = (tag: string) => {
91
91
  const regex = /^[a-zA-Z0-9-_]+$/
92
92
 
93
93
  if (!regex.test(tag)) {
94
- fail(`Flag "--bucket" has forbidden format. Allowed format: ${regex}.`)
94
+ halt(`Flag “--bucket has forbidden format. Allowed format: ${regex}.`)
95
95
  }
96
96
  }
97
97
 
@@ -101,7 +101,7 @@ const assertIsNotCore = () => {
101
101
  const {ifCore} = getIfCoreFns()
102
102
 
103
103
  if (ifCore()) {
104
- fail('You cannot deploy widget email configuration for Tamaro Core.')
104
+ halt('You cannot deploy widget email configuration for Tamaro Core.')
105
105
  }
106
106
  }
107
107
 
@@ -1,4 +1,5 @@
1
1
  import {existsSync} from 'fs'
2
+ import stripIndent from 'strip-indent'
2
3
  import {
3
4
  AWS_CLOUDFRONT_DISTRIBUTION_ID,
4
5
  AWS_S3_BUCKET,
@@ -13,7 +14,7 @@ import {
13
14
  import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
14
15
  import {logCommand, logDataTable, logTitle} from 'lib/logging'
15
16
  import {notify} from 'lib/notifier'
16
- import {fail, runCommandSync} from 'lib/command'
17
+ import {halt, runCommandSync} from 'lib/command'
17
18
 
18
19
  ///////////////////////////////////////////////////////////////////////////////
19
20
 
@@ -57,7 +58,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
57
58
  options,
58
59
  )
59
60
  } catch (error: any) {
60
- fail(error.stderr)
61
+ halt(error.stderr)
61
62
  }
62
63
 
63
64
  /////////////////////////////////////////////////////////////////////////////
@@ -79,7 +80,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
79
80
  options,
80
81
  )
81
82
  } catch (error: any) {
82
- fail(error.stderr)
83
+ halt(error.stderr)
83
84
  }
84
85
 
85
86
  /////////////////////////////////////////////////////////////////////////////
@@ -99,7 +100,7 @@ export const deploy = async (options: DeployOptions): Promise<void> => {
99
100
  // ignore output
100
101
  withAwsAuthenticate(() => runCommandSync(cmdInvalidateCache), options)
101
102
  } catch (error: any) {
102
- fail(error.stderr)
103
+ halt(error.stderr)
103
104
  }
104
105
 
105
106
  /////////////////////////////////////////////////////////////////////////////
@@ -140,10 +141,12 @@ const assertOptionsValid = (options: DeployOptions) => {
140
141
 
141
142
  const assertDistPathExists = (distPath: string) => {
142
143
  if (!existsSync(distPath)) {
143
- fail(`
144
- Dist folder does not exists.
145
- Make sure you have built the bundle before trying to deploy it.
146
- `)
144
+ halt(
145
+ stripIndent(`
146
+ Dist folder does not exists.
147
+ Make sure you have built the bundle before trying to deploy it.
148
+ `),
149
+ )
147
150
  }
148
151
  }
149
152
 
@@ -153,7 +156,7 @@ const assertTagValid = (tag: string) => {
153
156
  const regex = /^[a-zA-Z0-9-_.]+$/
154
157
 
155
158
  if (!regex.test(tag)) {
156
- fail(`Flag "--tag" has forbidden format. Allowed format: ${regex}.`)
159
+ halt(`Flag “--tag has forbidden format. Allowed format: ${regex}.`)
157
160
  }
158
161
  }
159
162
 
@@ -1,13 +1,15 @@
1
1
  import {getPortPromise} from 'portfinder'
2
2
  import {getIfCoreFns, resolveBin, resolveOwn} from 'lib/resolve'
3
3
  import {logCommand, logTitle} from 'lib/logging'
4
- import {fail, runCommandSync} from 'lib/command'
4
+ import {halt, runCommandSync} from 'lib/command'
5
+ import {assertEnvValid} from 'lib/env'
5
6
 
6
7
  ///////////////////////////////////////////////////////////////////////////////
7
8
 
8
9
  export type DevOptions = {
9
10
  localCore: boolean
10
11
  port: string
12
+ env: string
11
13
  }
12
14
 
13
15
  ///////////////////////////////////////////////////////////////////////////////
@@ -37,16 +39,18 @@ export const dev = async (options: DevOptions): Promise<void> => {
37
39
  ///////////////////////////////////////////////////////////////////////////////
38
40
 
39
41
  const assertOptionsValid = (options: DevOptions) => {
40
- const {localCore, port} = options
42
+ const {localCore, port, env} = options
41
43
  const {ifCore} = getIfCoreFns()
42
44
 
43
45
  if (ifCore() && localCore) {
44
- fail('Flag "--local-core" is redundant if running in Tamaro Core context.')
46
+ halt('Flag “--local-core is redundant if running in Tamaro Core context.')
45
47
  }
46
48
 
47
49
  if (isNaN(Number(port))) {
48
- fail('Flag "--port" should be a number.')
50
+ halt('Flag “--port should be a number.')
49
51
  }
52
+
53
+ assertEnvValid(env)
50
54
  }
51
55
 
52
56
  ///////////////////////////////////////////////////////////////////////////////
@@ -7,7 +7,7 @@ import {
7
7
  } from 'lib/aws'
8
8
  import {getIfCoreFns, getWidgetUuid} from 'lib/resolve'
9
9
  import {logCommand, logTitle} from 'lib/logging'
10
- import {fail, runCommandSync} from 'lib/command'
10
+ import {halt, runCommandSync} from 'lib/command'
11
11
 
12
12
  ///////////////////////////////////////////////////////////////////////////////
13
13
 
@@ -47,7 +47,7 @@ export const listDeployed = async (
47
47
  out = error.stdout
48
48
 
49
49
  if (error.stderr) {
50
- fail(error.stderr)
50
+ halt(error.stderr)
51
51
  }
52
52
  }
53
53
 
@@ -88,7 +88,7 @@ const assertConfigValid = (config: string | undefined) => {
88
88
  const regex = /^[a-zA-Z0-9-_]+$/
89
89
 
90
90
  if (!regex.test(config)) {
91
- fail(`Flag "--config" has forbidden format. Allowed format: ${regex}.`)
91
+ halt(`Flag “--config has forbidden format. Allowed format: ${regex}.`)
92
92
  }
93
93
  }
94
94