@raisenow/tamaro-cli 1.1.8 → 1.2.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/.history/.eslintignore_20220609190420 +4 -0
- package/.history/.eslintignore_20230911190227 +6 -0
- package/.history/.eslintignore_20230911211247 +7 -0
- package/.history/.eslintignore_20230911211250 +7 -0
- package/.history/.eslintrc_20230911201601.js +49 -0
- package/.history/.eslintrc_20230911201643.js +49 -0
- package/.history/.eslintrc_20230911201735.js +49 -0
- package/.history/.eslintrc_20230911201913.js +64 -0
- package/.history/.eslintrc_20230911202002.js +62 -0
- package/.history/.eslintrc_20230911202138.js +133 -0
- package/.history/.eslintrc_20230911202140.js +133 -0
- package/.history/.eslintrc_20230911202145.js +133 -0
- package/.history/.eslintrc_20230911202147.js +133 -0
- package/.history/.eslintrc_20230911202406.js +133 -0
- package/.history/.eslintrc_20230911202447.js +133 -0
- package/.history/.eslintrc_20230911202453.js +133 -0
- package/.history/.eslintrc_20230911202511.js +133 -0
- package/.history/.eslintrc_20230911202527.js +133 -0
- package/.history/.eslintrc_20230911202639.js +125 -0
- package/.history/.eslintrc_20230911202721.js +149 -0
- package/.history/.eslintrc_20230911202746.js +149 -0
- package/.history/.eslintrc_20240423125702.cjs +148 -0
- package/.history/.gitignore_20220609190420 +14 -0
- package/.history/.gitignore_20230911185959 +4 -0
- package/.history/.gitignore_20230911190006 +4 -0
- package/.history/.gitignore_20230911190007 +4 -0
- package/.history/.nmprc_20241004144025 +0 -0
- package/.history/.nmprc_20241004144041 +1 -0
- package/.history/.npmrc_20241004144040 +1 -0
- package/.history/.npmrc_20241004144152 +1 -0
- package/.history/.npmrc_20241004145639 +2 -0
- package/.history/.npmrc_20241004145649 +1 -0
- package/.history/.nvmrc_20241125012803 +1 -0
- package/.history/.nvmrc_20241125022800 +1 -0
- package/.history/.nvmrc_20241125022806 +1 -0
- package/.history/.prettierignore_20220609190420 +5 -0
- package/.history/.prettierignore_20230911190242 +7 -0
- package/.history/.prettierignore_20230911190245 +7 -0
- package/.history/.prettierignore_20230911211301 +8 -0
- package/.history/CHANGELOG_20250624052910.md +20 -0
- package/.history/CHANGELOG_20250624055058.md +23 -0
- package/.history/CHANGELOG_20250624055107.md +23 -0
- package/.history/CHANGELOG_20250624055138.md +23 -0
- package/.history/CHANGELOG_20250624055156.md +23 -0
- package/.history/CHANGELOG_20250624055200.md +23 -0
- package/.history/CHANGELOG_20250624055203.md +23 -0
- package/.history/CHANGELOG_20250625142852.md +25 -0
- package/.history/CHANGELOG_20250625142901.md +22 -0
- package/.history/CHANGELOG_20250625142902.md +22 -0
- package/.history/README_20230911145033.md +245 -0
- package/.history/README_20230911151749.md +245 -0
- package/.history/README_20230911151844.md +245 -0
- package/.history/README_20230911153040.md +245 -0
- package/.history/README_20230911202959.md +245 -0
- package/.history/cli_20241005014539 +3 -0
- package/.history/cli_20241005014542 +3 -0
- package/.history/cli_20241005014848 +3 -0
- package/.history/dist/chunk-FICM3HUI_20230912183408.js +302 -0
- package/.history/dist/chunk-FICM3HUI_20230912201610.js +302 -0
- package/.history/package_20241107122123.json +106 -0
- package/.history/package_20241107122219.json +106 -0
- package/.history/package_20241107124611.json +106 -0
- package/.history/package_20241107125521.json +106 -0
- package/.history/package_20241107125538.json +106 -0
- package/.history/package_20241125013228.json +106 -0
- package/.history/package_20241125013249.json +106 -0
- package/.history/package_20241125014402.json +105 -0
- package/.history/package_20241125103106.json +105 -0
- package/.history/tsconfig_20241005001442.json +34 -0
- package/.history/tsconfig_20241005001500.json +34 -0
- package/.history/tsconfig_20241005001540.json +34 -0
- package/.history/tsconfig_20241005014429.json +42 -0
- package/.history/tsconfig_20241005014436.json +42 -0
- package/.history/tsconfig_20241005014439.json +38 -0
- package/.history/tsconfig_20241005014455.json +38 -0
- package/.idea/codeStyles/Project.xml +131 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +17 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/tamaro-cli.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +35 -13
- package/bitbucket-pipelines.yml +43 -0
- package/dist/cli.js +42 -1
- package/dist/webpack.config.js +43 -12
- package/package.json +5 -1
- package/src/cli.ts +0 -178
- package/src/commands/build.ts +0 -131
- package/src/commands/deploy-email-config.ts +0 -159
- package/src/commands/deploy.ts +0 -164
- package/src/commands/dev.ts +0 -88
- package/src/commands/list-deployed.ts +0 -117
- package/src/commands/serve.ts +0 -69
- package/src/lib/InterpolateHtmlPlugin.ts +0 -47
- package/src/lib/aws.ts +0 -138
- package/src/lib/command.ts +0 -27
- package/src/lib/constants.ts +0 -9
- package/src/lib/env.ts +0 -175
- package/src/lib/https.ts +0 -27
- package/src/lib/logging.ts +0 -37
- package/src/lib/notifier.ts +0 -22
- package/src/lib/resolve.ts +0 -143
- package/src/webpack.config.ts +0 -437
- /package/{tsconfig.json → .history/tsconfig_20241005014521.json} +0 -0
package/dist/cli.js
CHANGED
|
@@ -27,6 +27,37 @@ import {
|
|
|
27
27
|
// src/cli.ts
|
|
28
28
|
import { createCommand } from "commander";
|
|
29
29
|
|
|
30
|
+
// src/commands/validate.ts
|
|
31
|
+
import { glob } from "glob";
|
|
32
|
+
|
|
33
|
+
// src/lib/validators/validateEmailTemplates.ts
|
|
34
|
+
import fs from "node:fs/promises";
|
|
35
|
+
import handlebars from "handlebars";
|
|
36
|
+
var { compile } = handlebars;
|
|
37
|
+
var validateEmailTemplates = async (templateFiles) => {
|
|
38
|
+
const errors = [];
|
|
39
|
+
for (const templateFile of templateFiles) {
|
|
40
|
+
try {
|
|
41
|
+
const compiled = compile(await fs.readFile(templateFile, "utf-8"));
|
|
42
|
+
compiled({});
|
|
43
|
+
console.log(`${templateFile} is a valid email template`);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
errors.push(`${templateFile} is invalid`);
|
|
46
|
+
errors.push(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return errors;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/commands/validate.ts
|
|
53
|
+
var validate = async () => {
|
|
54
|
+
const errors = await validateEmailTemplates(await glob("email-config/templates/**/*.hbs"));
|
|
55
|
+
if (errors.length) {
|
|
56
|
+
halt(errors.map((el) => el.toString()).join("\n"));
|
|
57
|
+
}
|
|
58
|
+
logTitle("Valid. Bye.");
|
|
59
|
+
};
|
|
60
|
+
|
|
30
61
|
// src/lib/aws.ts
|
|
31
62
|
import { execaCommandSync } from "execa";
|
|
32
63
|
import prompts from "prompts";
|
|
@@ -151,6 +182,7 @@ var build = async (options) => {
|
|
|
151
182
|
options.profile = await promptProfile();
|
|
152
183
|
}
|
|
153
184
|
assertOptionsValid(options);
|
|
185
|
+
await validate();
|
|
154
186
|
const flags = prepareFlags2(options);
|
|
155
187
|
const { ifCore } = getIfCoreFns();
|
|
156
188
|
const paths = getPaths(ifCore);
|
|
@@ -228,6 +260,7 @@ var deploy = async (options) => {
|
|
|
228
260
|
options.profile = await promptProfile();
|
|
229
261
|
}
|
|
230
262
|
assertOptionsValid2(options);
|
|
263
|
+
await validate();
|
|
231
264
|
awsAuthenticate(options);
|
|
232
265
|
const flags = prepareFlags(options);
|
|
233
266
|
const { tag } = options;
|
|
@@ -335,6 +368,7 @@ var deployEmailConfig = async (options) => {
|
|
|
335
368
|
options.bucket = options.ci ? AWS_S3_BUCKET_TAMARO_EMAIL_CONFIG_PROD : await promptBucketTamaroEmailConfig();
|
|
336
369
|
}
|
|
337
370
|
assertOptionsValid3(options);
|
|
371
|
+
await validate();
|
|
338
372
|
awsAuthenticate(options);
|
|
339
373
|
const flags = prepareFlags(options);
|
|
340
374
|
const configName = getWidgetUuid();
|
|
@@ -577,7 +611,7 @@ var prepareFlags4 = async (options) => {
|
|
|
577
611
|
// package.json
|
|
578
612
|
var package_default = {
|
|
579
613
|
name: "@raisenow/tamaro-cli",
|
|
580
|
-
version: "1.
|
|
614
|
+
version: "1.2.0",
|
|
581
615
|
author: {
|
|
582
616
|
name: "RaiseNow",
|
|
583
617
|
email: "development@raisenow.com"
|
|
@@ -650,6 +684,8 @@ var package_default = {
|
|
|
650
684
|
"file-loader": "^6.2.0",
|
|
651
685
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
652
686
|
glob: "^11.0.0",
|
|
687
|
+
handlebars: "^4.7.8",
|
|
688
|
+
"handlebars-helpers": "^0.10.0",
|
|
653
689
|
"html-loader": "^5.1.0",
|
|
654
690
|
"html-webpack-plugin": "^5.6.3",
|
|
655
691
|
"json-loader": "^0.5.7",
|
|
@@ -659,7 +695,9 @@ var package_default = {
|
|
|
659
695
|
portfinder: "^1.0.32",
|
|
660
696
|
postcss: "^8.4.49",
|
|
661
697
|
"postcss-custom-properties": "^14.0.4",
|
|
698
|
+
"postcss-import": "^16.1.1",
|
|
662
699
|
"postcss-loader": "^8.1.1",
|
|
700
|
+
"postcss-nested": "^7.0.2",
|
|
663
701
|
prettier: "^3.3.3",
|
|
664
702
|
prompts: "^2.4.2",
|
|
665
703
|
"react-refresh": "^0.14.2",
|
|
@@ -756,6 +794,9 @@ cli.command("list-deployed").description(
|
|
|
756
794
|
cli.command("deploy-email-config").description("Deploy a widget's email configuration to AWS S3").option("--profile <profile>", "AWS profile").option("--ci", "CI environment", false).option("--bucket <bucket>", "AWS bucket for email configs").action(async (options) => {
|
|
757
795
|
await deployEmailConfig(options);
|
|
758
796
|
});
|
|
797
|
+
cli.command("validate").description("Validate the current Tamaro configuration to avoid common errors").action(async () => {
|
|
798
|
+
await validate();
|
|
799
|
+
});
|
|
759
800
|
(async () => {
|
|
760
801
|
try {
|
|
761
802
|
logTitle(`${package_default.name} ${package_default.version}
|
package/dist/webpack.config.js
CHANGED
|
@@ -83,8 +83,10 @@ var getWebpackConfig = (env) => {
|
|
|
83
83
|
logDataTable(envVars.raw);
|
|
84
84
|
const getCssLoaders = ({
|
|
85
85
|
styleLoader = true,
|
|
86
|
+
sassLoader = true,
|
|
86
87
|
...cssOptions
|
|
87
88
|
}) => {
|
|
89
|
+
const importLoaders = sassLoader ? 3 : 1;
|
|
88
90
|
return removeEmpty([
|
|
89
91
|
styleLoader ? ifMin({ loader: MiniCssExtractPlugin.loader }) : void 0,
|
|
90
92
|
styleLoader ? ifNotMin({
|
|
@@ -99,7 +101,7 @@ var getWebpackConfig = (env) => {
|
|
|
99
101
|
loader: require2.resolve("css-loader"),
|
|
100
102
|
options: {
|
|
101
103
|
sourceMap: ifNotMin(),
|
|
102
|
-
importLoaders
|
|
104
|
+
importLoaders,
|
|
103
105
|
...cssOptions
|
|
104
106
|
}
|
|
105
107
|
},
|
|
@@ -108,26 +110,28 @@ var getWebpackConfig = (env) => {
|
|
|
108
110
|
options: {
|
|
109
111
|
postcssOptions: {
|
|
110
112
|
plugins: removeEmpty([
|
|
113
|
+
!sassLoader ? require2.resolve("postcss-import") : void 0,
|
|
114
|
+
!sassLoader ? require2.resolve("postcss-nested") : void 0,
|
|
111
115
|
useTailwind ? [
|
|
112
116
|
require2.resolve("tailwindcss", {
|
|
113
117
|
paths: [paths.appNodeModules]
|
|
114
118
|
}),
|
|
115
119
|
paths.appTailwindConfig
|
|
116
120
|
] : void 0,
|
|
117
|
-
|
|
121
|
+
// require.resolve('postcss-custom-properties'),
|
|
118
122
|
require2.resolve("autoprefixer")
|
|
119
123
|
])
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
},
|
|
123
|
-
{
|
|
127
|
+
sassLoader ? {
|
|
124
128
|
loader: require2.resolve("resolve-url-loader"),
|
|
125
129
|
options: { sourceMap: ifNotMin() }
|
|
126
|
-
},
|
|
127
|
-
{
|
|
130
|
+
} : void 0,
|
|
131
|
+
sassLoader ? {
|
|
128
132
|
loader: require2.resolve("sass-loader"),
|
|
129
133
|
options: { api: "modern-compiler", sourceMap: true }
|
|
130
|
-
}
|
|
134
|
+
} : void 0
|
|
131
135
|
]);
|
|
132
136
|
};
|
|
133
137
|
const config = {
|
|
@@ -206,7 +210,12 @@ var getWebpackConfig = (env) => {
|
|
|
206
210
|
allowDeclareFields: true
|
|
207
211
|
}
|
|
208
212
|
],
|
|
209
|
-
|
|
213
|
+
[
|
|
214
|
+
require2.resolve("@babel/preset-react"),
|
|
215
|
+
{
|
|
216
|
+
runtime: "automatic"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
210
219
|
],
|
|
211
220
|
plugins: removeEmpty([
|
|
212
221
|
[
|
|
@@ -238,20 +247,42 @@ var getWebpackConfig = (env) => {
|
|
|
238
247
|
{
|
|
239
248
|
test: /\.(js|mjs)$/
|
|
240
249
|
},
|
|
241
|
-
// Styles (extracted)
|
|
250
|
+
// SCSS Styles (extracted)
|
|
251
|
+
{
|
|
252
|
+
test: /\.scss$/,
|
|
253
|
+
resourceQuery: { not: [/inline/] },
|
|
254
|
+
use: getCssLoaders({
|
|
255
|
+
styleLoader: true,
|
|
256
|
+
sassLoader: true
|
|
257
|
+
})
|
|
258
|
+
},
|
|
259
|
+
// CSS Styles (extracted)
|
|
242
260
|
{
|
|
243
|
-
test: /\.
|
|
261
|
+
test: /\.css$/,
|
|
244
262
|
resourceQuery: { not: [/inline/] },
|
|
245
263
|
use: getCssLoaders({
|
|
246
|
-
styleLoader: true
|
|
264
|
+
styleLoader: true,
|
|
265
|
+
sassLoader: false
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
// SCSS Styles (as string)
|
|
269
|
+
{
|
|
270
|
+
test: /\.scss$/,
|
|
271
|
+
resourceQuery: /inline/,
|
|
272
|
+
use: getCssLoaders({
|
|
273
|
+
styleLoader: false,
|
|
274
|
+
sassLoader: true,
|
|
275
|
+
exportType: "string",
|
|
276
|
+
sourceMap: false
|
|
247
277
|
})
|
|
248
278
|
},
|
|
249
|
-
// Styles (as string)
|
|
279
|
+
// CSS Styles (as string)
|
|
250
280
|
{
|
|
251
|
-
test: /\.
|
|
281
|
+
test: /\.css$/,
|
|
252
282
|
resourceQuery: /inline/,
|
|
253
283
|
use: getCssLoaders({
|
|
254
284
|
styleLoader: false,
|
|
285
|
+
sassLoader: false,
|
|
255
286
|
exportType: "string",
|
|
256
287
|
sourceMap: false
|
|
257
288
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raisenow/tamaro-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "RaiseNow",
|
|
6
6
|
"email": "development@raisenow.com"
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
"file-loader": "^6.2.0",
|
|
74
74
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
75
75
|
"glob": "^11.0.0",
|
|
76
|
+
"handlebars": "^4.7.8",
|
|
77
|
+
"handlebars-helpers": "^0.10.0",
|
|
76
78
|
"html-loader": "^5.1.0",
|
|
77
79
|
"html-webpack-plugin": "^5.6.3",
|
|
78
80
|
"json-loader": "^0.5.7",
|
|
@@ -82,7 +84,9 @@
|
|
|
82
84
|
"portfinder": "^1.0.32",
|
|
83
85
|
"postcss": "^8.4.49",
|
|
84
86
|
"postcss-custom-properties": "^14.0.4",
|
|
87
|
+
"postcss-import": "^16.1.1",
|
|
85
88
|
"postcss-loader": "^8.1.1",
|
|
89
|
+
"postcss-nested": "^7.0.2",
|
|
86
90
|
"prettier": "^3.3.3",
|
|
87
91
|
"prompts": "^2.4.2",
|
|
88
92
|
"react-refresh": "^0.14.2",
|
package/src/cli.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import {createCommand} from 'commander'
|
|
4
|
-
import {build, type BuildOptions} from 'commands/build'
|
|
5
|
-
import {deploy, type DeployOptions} from 'commands/deploy'
|
|
6
|
-
import {
|
|
7
|
-
deployEmailConfig,
|
|
8
|
-
type DeployEmailConfigOptions,
|
|
9
|
-
} from 'commands/deploy-email-config'
|
|
10
|
-
import {dev, type DevOptions} from 'commands/dev'
|
|
11
|
-
import {listDeployed, type ListDeployedOptions} from 'commands/list-deployed'
|
|
12
|
-
import {serve, type ServeOptions} from 'commands/serve'
|
|
13
|
-
import {halt} from 'lib/command'
|
|
14
|
-
import {DEFAULT_PORT, DEFAULT_TAG} from 'lib/constants'
|
|
15
|
-
import {logError, logTitle} from 'lib/logging'
|
|
16
|
-
import pkg from '../package.json'
|
|
17
|
-
|
|
18
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Makes the script crash on unhandled rejections instead of silently
|
|
22
|
-
* ignoring them. In the future, promise rejections that are not handled will
|
|
23
|
-
* terminate the Node.js process with a non-zero exit code.
|
|
24
|
-
*/
|
|
25
|
-
process.on('unhandledRejection', (error) => {
|
|
26
|
-
throw error
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// Exit on ctrl+c
|
|
30
|
-
process.on('SIGINT', () => {
|
|
31
|
-
halt()
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
35
|
-
|
|
36
|
-
const cli = createCommand().name(pkg.name).version(pkg.version, '-v, --version')
|
|
37
|
-
|
|
38
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
39
|
-
|
|
40
|
-
cli
|
|
41
|
-
.command('dev')
|
|
42
|
-
.description(
|
|
43
|
-
'Run the local development server for Tamaro Core or a particular customer configuration',
|
|
44
|
-
)
|
|
45
|
-
.option(
|
|
46
|
-
'--local-core',
|
|
47
|
-
'Load Tamaro Core from localhost:1234 instead of the CDN',
|
|
48
|
-
false,
|
|
49
|
-
)
|
|
50
|
-
.option(
|
|
51
|
-
'--https',
|
|
52
|
-
'Let local web server serve Tamaro with SSL encryption',
|
|
53
|
-
false,
|
|
54
|
-
)
|
|
55
|
-
.option('--port <port>', 'Web server port', `${DEFAULT_PORT}`)
|
|
56
|
-
.option('--env <env>', 'Environment (dev, stage, prod)')
|
|
57
|
-
.option('--nolint', 'Disable ESLint', false)
|
|
58
|
-
.action(async (options: DevOptions) => {
|
|
59
|
-
await dev(options)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
cli
|
|
63
|
-
.command('build')
|
|
64
|
-
.description(
|
|
65
|
-
'Build an optimised (minified) bundle of Tamaro Core or a customer configuration',
|
|
66
|
-
)
|
|
67
|
-
.option(
|
|
68
|
-
'--local-core',
|
|
69
|
-
'Load Tamaro Core from localhost:1234 instead of the CDN',
|
|
70
|
-
false,
|
|
71
|
-
)
|
|
72
|
-
.option('--analyze', 'Generate bundle statistics to "reports" folder', false)
|
|
73
|
-
.option('--serve', 'Run the generated bundle with a local web server', false)
|
|
74
|
-
.option(
|
|
75
|
-
'--https',
|
|
76
|
-
'Let local web server serve Tamaro with SSL encryption',
|
|
77
|
-
false,
|
|
78
|
-
)
|
|
79
|
-
.option('--port <port>', 'Web server port', `${DEFAULT_PORT}`)
|
|
80
|
-
.option('--env <env>', 'Environment (dev, stage, prod)')
|
|
81
|
-
.option('--profile <profile>', 'AWS profile')
|
|
82
|
-
.option('--ci', 'CI environment', false)
|
|
83
|
-
.option(
|
|
84
|
-
'--deploy',
|
|
85
|
-
'Deploy Tamaro Core or a customer configuration bundle to AWS S3',
|
|
86
|
-
false,
|
|
87
|
-
)
|
|
88
|
-
.option(
|
|
89
|
-
'--tag <tag>',
|
|
90
|
-
'Tag which should be used for the deployment of the bundle',
|
|
91
|
-
DEFAULT_TAG,
|
|
92
|
-
)
|
|
93
|
-
.option('--nolint', 'Disable ESLint', false)
|
|
94
|
-
.action(async (options: BuildOptions & ServeOptions & DeployOptions) => {
|
|
95
|
-
await build(options)
|
|
96
|
-
|
|
97
|
-
if (options.serve) {
|
|
98
|
-
await serve(options)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (options.deploy) {
|
|
102
|
-
await deploy(options)
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
cli
|
|
107
|
-
.command('serve')
|
|
108
|
-
.description('Run a local web server for pre-built bundle')
|
|
109
|
-
.option('--port <port>', 'Web server port', `${DEFAULT_PORT}`)
|
|
110
|
-
.option(
|
|
111
|
-
'--https',
|
|
112
|
-
'Let local web server serve Tamaro with SSL encryption',
|
|
113
|
-
false,
|
|
114
|
-
)
|
|
115
|
-
.action(async (options: ServeOptions) => {
|
|
116
|
-
await serve(options)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
cli
|
|
120
|
-
.command('deploy')
|
|
121
|
-
.description(
|
|
122
|
-
'Deploy a pre-built Tamaro Core or customer configuration bundle to AWS S3',
|
|
123
|
-
)
|
|
124
|
-
.option('--profile <profile>', 'AWS profile')
|
|
125
|
-
.option('--ci', 'CI environment', false)
|
|
126
|
-
.option(
|
|
127
|
-
'--tag <tag>',
|
|
128
|
-
'Tag which should be used for the deployment of the bundle',
|
|
129
|
-
DEFAULT_TAG,
|
|
130
|
-
)
|
|
131
|
-
.action(async (options: DeployOptions) => {
|
|
132
|
-
await deploy(options)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
cli
|
|
136
|
-
.command('list-deployed')
|
|
137
|
-
.description(
|
|
138
|
-
'List deployments of Tamaro Core or a particular customer configuration',
|
|
139
|
-
)
|
|
140
|
-
.option('--profile <profile>', 'AWS profile')
|
|
141
|
-
.option('--ci', 'CI environment', false)
|
|
142
|
-
.option(
|
|
143
|
-
'--config <config>',
|
|
144
|
-
'Configuration name (default: current customer configuration)',
|
|
145
|
-
)
|
|
146
|
-
.action(async (options: ListDeployedOptions) => {
|
|
147
|
-
await listDeployed(options)
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
cli
|
|
151
|
-
.command('deploy-email-config')
|
|
152
|
-
.description("Deploy a widget's email configuration to AWS S3")
|
|
153
|
-
.option('--profile <profile>', 'AWS profile')
|
|
154
|
-
.option('--ci', 'CI environment', false)
|
|
155
|
-
.option('--bucket <bucket>', 'AWS bucket for email configs')
|
|
156
|
-
.action(async (options: DeployEmailConfigOptions) => {
|
|
157
|
-
await deployEmailConfig(options)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
161
|
-
|
|
162
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
163
|
-
;(async () => {
|
|
164
|
-
try {
|
|
165
|
-
logTitle(`${pkg.name} ${pkg.version}\n`)
|
|
166
|
-
|
|
167
|
-
await cli.parseAsync(process.argv)
|
|
168
|
-
} catch (error: any) {
|
|
169
|
-
if (error.signal === 'SIGINT' && error.signalDescription) {
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
171
|
-
logError(`\n${error.signalDescription}`)
|
|
172
|
-
} else {
|
|
173
|
-
// eslint-disable-next-line no-console
|
|
174
|
-
console.log('')
|
|
175
|
-
logError(error.stack)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
})()
|
package/src/commands/build.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {type DeployOptions} from 'commands/deploy'
|
|
2
|
-
import {assertProfilesPresent, assertProfileValid, promptProfile} from 'lib/aws'
|
|
3
|
-
import {halt, runCommandSync} from 'lib/command'
|
|
4
|
-
import {CORE_CONFIG_NAME} from 'lib/constants'
|
|
5
|
-
import {applyEnv, assertEnvValid} from 'lib/env'
|
|
6
|
-
import {assertCrtExists} from 'lib/https'
|
|
7
|
-
import {logCommand, logTitle} from 'lib/logging'
|
|
8
|
-
import {notify} from 'lib/notifier'
|
|
9
|
-
import {
|
|
10
|
-
getIfCoreFns,
|
|
11
|
-
getPaths,
|
|
12
|
-
getWidgetUuid,
|
|
13
|
-
resolveBin,
|
|
14
|
-
resolveOwn,
|
|
15
|
-
} from 'lib/resolve'
|
|
16
|
-
|
|
17
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
18
|
-
|
|
19
|
-
export type BuildOptions = {
|
|
20
|
-
localCore: boolean
|
|
21
|
-
analyze: boolean
|
|
22
|
-
https: boolean
|
|
23
|
-
serve: boolean
|
|
24
|
-
deploy: boolean
|
|
25
|
-
env?: string
|
|
26
|
-
nolint: boolean
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
30
|
-
|
|
31
|
-
export const build = async (
|
|
32
|
-
options: BuildOptions & DeployOptions,
|
|
33
|
-
): Promise<void> => {
|
|
34
|
-
const {env} = options
|
|
35
|
-
|
|
36
|
-
applyEnv(env)
|
|
37
|
-
|
|
38
|
-
if (options.deploy && !options.profile && !options.ci) {
|
|
39
|
-
assertProfilesPresent()
|
|
40
|
-
options.profile = await promptProfile()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
assertOptionsValid(options)
|
|
44
|
-
|
|
45
|
-
const flags = prepareFlags(options)
|
|
46
|
-
const {ifCore} = getIfCoreFns()
|
|
47
|
-
const paths = getPaths(ifCore)
|
|
48
|
-
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid())
|
|
49
|
-
const title = ifCore(
|
|
50
|
-
'Building optimised (minified) bundle of Tamaro Core …',
|
|
51
|
-
`Building optimised (minified) bundle of "${configName}" customer configuration …`,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
const wpBin = resolveBin('webpack')
|
|
55
|
-
const wpConfig = resolveOwn('dist/webpack.config.js')
|
|
56
|
-
const cmd = `
|
|
57
|
-
${wpBin}
|
|
58
|
-
--config ${wpConfig}
|
|
59
|
-
--env min
|
|
60
|
-
${flags}
|
|
61
|
-
`
|
|
62
|
-
|
|
63
|
-
logTitle(title)
|
|
64
|
-
logCommand(cmd)
|
|
65
|
-
runCommandSync(cmd, {stdio: 'inherit'})
|
|
66
|
-
|
|
67
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
68
|
-
|
|
69
|
-
logTitle(`\nBundle for "${configName}" customer configuration is done.`)
|
|
70
|
-
// eslint-disable-next-line no-console
|
|
71
|
-
console.log(`Path: ${paths.appDist}\n`)
|
|
72
|
-
|
|
73
|
-
/////////////////////////////////////////////////////////////////////////////
|
|
74
|
-
|
|
75
|
-
process.on('exit', () => {
|
|
76
|
-
notify({
|
|
77
|
-
title: 'build',
|
|
78
|
-
message: `Bundle for "${configName}" customer configuration is done.`,
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
84
|
-
|
|
85
|
-
const assertOptionsValid = (options: BuildOptions & DeployOptions) => {
|
|
86
|
-
const {localCore, https, deploy, env, profile} = options
|
|
87
|
-
const {ifCore} = getIfCoreFns()
|
|
88
|
-
|
|
89
|
-
if (ifCore() && localCore) {
|
|
90
|
-
halt('Flag "--local-core" is redundant if running in Tamaro Core context.')
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (localCore && deploy) {
|
|
94
|
-
halt('Flags "--local-core" and "--deploy" must not be used together.')
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (https) {
|
|
98
|
-
assertCrtExists()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (profile) {
|
|
102
|
-
assertProfileValid(profile)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
assertEnvValid(env)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
109
|
-
|
|
110
|
-
const prepareFlags = (options: BuildOptions) => {
|
|
111
|
-
const flags: string[] = []
|
|
112
|
-
const {localCore, analyze, https, nolint} = options
|
|
113
|
-
|
|
114
|
-
if (localCore) {
|
|
115
|
-
flags.push('--env localCore')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (analyze) {
|
|
119
|
-
flags.push('--env analyze')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (https) {
|
|
123
|
-
flags.push('--env https')
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (nolint) {
|
|
127
|
-
flags.push('--env nolint')
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return flags.join(' ')
|
|
131
|
-
}
|