@raisenow/tamaro-cli 1.0.26 → 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-ZAKDPU5F.js → chunk-S4M23KNZ.js} +35 -33
- package/dist/cli.js +331 -329
- package/dist/webpack.config.js +19 -19
- package/package.json +62 -57
- package/readme.html +1 -1
- package/src/cli.ts +12 -44
- package/src/commands/build.ts +19 -14
- package/src/commands/deploy-email-config.ts +19 -52
- package/src/commands/deploy.ts +18 -19
- package/src/commands/dev.ts +4 -4
- 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 +12 -13
- 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 +18 -17
- package/tsconfig.json +5 -1
- package/.gitignore +0 -14
- package/tsconfig.eslint.json +0 -7
package/dist/webpack.config.js
CHANGED
|
@@ -10,29 +10,29 @@ import {
|
|
|
10
10
|
logTitle,
|
|
11
11
|
moduleFileExtensions,
|
|
12
12
|
resolveApp
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-S4M23KNZ.js";
|
|
14
14
|
|
|
15
15
|
// src/webpack.config.ts
|
|
16
|
+
import { existsSync } from "fs";
|
|
16
17
|
import { createRequire } from "module";
|
|
17
18
|
import { basename, dirname, resolve } from "path";
|
|
18
|
-
import { existsSync } from "fs";
|
|
19
|
-
import { globSync } from "glob";
|
|
20
|
-
import { getIfUtils, removeEmpty } from "webpack-config-utils";
|
|
21
|
-
import webpack from "webpack";
|
|
22
|
-
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
|
|
23
|
-
import { CleanWebpackPlugin } from "clean-webpack-plugin";
|
|
24
|
-
import HtmlWebpackPlugin2 from "html-webpack-plugin";
|
|
25
|
-
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
|
26
19
|
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
|
|
27
|
-
import
|
|
20
|
+
import StatoscopeWebpackPlugin from "@statoscope/webpack-plugin";
|
|
21
|
+
import { CleanWebpackPlugin } from "clean-webpack-plugin";
|
|
22
|
+
import CopyPlugin from "copy-webpack-plugin";
|
|
28
23
|
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
29
24
|
import ESLintPlugin from "eslint-webpack-plugin";
|
|
30
|
-
import
|
|
31
|
-
import
|
|
25
|
+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
|
|
26
|
+
import { globSync } from "glob";
|
|
27
|
+
import HtmlWebpackPlugin2 from "html-webpack-plugin";
|
|
28
|
+
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
29
|
+
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
|
|
30
|
+
import webpack from "webpack";
|
|
31
|
+
import { getIfUtils, removeEmpty } from "webpack-config-utils";
|
|
32
32
|
|
|
33
33
|
// src/lib/InterpolateHtmlPlugin.ts
|
|
34
|
-
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
35
34
|
import escapeStringRegexp from "escape-string-regexp";
|
|
35
|
+
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
36
36
|
var PLUGIN_NAME = "InterpolateHtmlPlugin";
|
|
37
37
|
var InterpolateHtmlPlugin = class {
|
|
38
38
|
replacements;
|
|
@@ -43,16 +43,16 @@ var InterpolateHtmlPlugin = class {
|
|
|
43
43
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
44
44
|
const hooks = HtmlWebpackPlugin.getHooks(compilation);
|
|
45
45
|
hooks.alterAssetTagGroups.tap(PLUGIN_NAME, (assets) => {
|
|
46
|
-
const publicUrl = this.replacements
|
|
47
|
-
const entry = assets.headTags[0].attributes
|
|
48
|
-
this.replacements
|
|
46
|
+
const publicUrl = this.replacements.PUBLIC_URL ?? "";
|
|
47
|
+
const entry = assets.headTags[0].attributes.src;
|
|
48
|
+
this.replacements.ENTRY = `${publicUrl}${entry}`;
|
|
49
49
|
return assets;
|
|
50
50
|
});
|
|
51
51
|
hooks.afterTemplateExecution.tap(PLUGIN_NAME, (data) => {
|
|
52
52
|
Object.entries(this.replacements).forEach(([key, value]) => {
|
|
53
53
|
data.html = data.html.replace(
|
|
54
54
|
new RegExp(`%${escapeStringRegexp(key)}%`, "g"),
|
|
55
|
-
value
|
|
55
|
+
value ?? ""
|
|
56
56
|
);
|
|
57
57
|
});
|
|
58
58
|
return data;
|
|
@@ -64,7 +64,7 @@ var InterpolateHtmlPlugin = class {
|
|
|
64
64
|
// src/webpack.config.ts
|
|
65
65
|
var require2 = createRequire(import.meta.url);
|
|
66
66
|
var imageInlineSizeLimit = 0;
|
|
67
|
-
var getWebpackConfig =
|
|
67
|
+
var getWebpackConfig = (env) => {
|
|
68
68
|
const { ifMin, ifNotMin } = getIfUtils(env, ["min"]);
|
|
69
69
|
const { ifAnalyze } = getIfUtils(env, ["analyze"]);
|
|
70
70
|
const { ifHttps } = getIfUtils(env, ["https"]);
|
|
@@ -105,7 +105,6 @@ var getWebpackConfig = async (env) => {
|
|
|
105
105
|
postcssOptions: {
|
|
106
106
|
plugins: removeEmpty([
|
|
107
107
|
useTailwind ? [
|
|
108
|
-
// eslint-disable-next-line node/no-missing-require
|
|
109
108
|
require2.resolve("tailwindcss", {
|
|
110
109
|
paths: [paths.appNodeModules]
|
|
111
110
|
}),
|
|
@@ -386,6 +385,7 @@ var getWebpackConfig = async (env) => {
|
|
|
386
385
|
resourceRegExp: /^\.\/locale$/,
|
|
387
386
|
contextRegExp: /moment$/
|
|
388
387
|
}),
|
|
388
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
389
389
|
ifMin(new webpack.ids.HashedModuleIdsPlugin()),
|
|
390
390
|
// todo: remove?
|
|
391
391
|
ifMin() && ifCore() ? new CopyPlugin({
|
package/package.json
CHANGED
|
@@ -1,99 +1,104 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raisenow/tamaro-cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "RaiseNow",
|
|
6
6
|
"email": "development@raisenow.com"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"prepare": "
|
|
11
|
-
"
|
|
10
|
+
"prepare": "pnpm build",
|
|
11
|
+
"tscheck": "tsc --noEmit",
|
|
12
12
|
"build": "tsup src/cli.ts src/webpack.config.ts --clean --shims --format esm",
|
|
13
|
-
"build:watch": "
|
|
14
|
-
"
|
|
15
|
-
"lint": "eslint
|
|
13
|
+
"build:watch": "pnpm build --watch --ignore-watch .history --ignore-watch .idea",
|
|
14
|
+
"readme": "pnpx http-server . --cors -o /readme.html",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"lint:fix": "eslint --fix .",
|
|
17
|
+
"format": "prettier --write ."
|
|
16
18
|
},
|
|
17
19
|
"bin": "dist/cli.js",
|
|
18
20
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
20
|
-
"npm": ">=
|
|
21
|
+
"node": ">=18",
|
|
22
|
+
"npm": ">=10"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|
|
23
|
-
"@babel/cli": "^7.
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
25
|
+
"@babel/cli": "^7.22.15",
|
|
26
|
+
"@babel/core": "^7.22.17",
|
|
27
|
+
"@babel/plugin-proposal-decorators": "^7.22.15",
|
|
26
28
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
27
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
28
|
-
"@babel/preset-env": "^7.
|
|
29
|
-
"@babel/preset-react": "^7.
|
|
30
|
-
"@babel/preset-typescript": "^7.
|
|
31
|
-
"@babel/runtime-corejs3": "^7.
|
|
32
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
33
|
-
"@statoscope/webpack-plugin": "^5.
|
|
34
|
-
"@types/columnify": "^1.5.
|
|
35
|
-
"@types/lodash": "^4.14.
|
|
36
|
-
"@types/node": "^18.15
|
|
29
|
+
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
30
|
+
"@babel/preset-env": "^7.22.15",
|
|
31
|
+
"@babel/preset-react": "^7.22.15",
|
|
32
|
+
"@babel/preset-typescript": "^7.22.15",
|
|
33
|
+
"@babel/runtime-corejs3": "^7.22.15",
|
|
34
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
35
|
+
"@statoscope/webpack-plugin": "^5.27.0",
|
|
36
|
+
"@types/columnify": "^1.5.2",
|
|
37
|
+
"@types/lodash": "^4.14.198",
|
|
38
|
+
"@types/node": "^18.17.15",
|
|
37
39
|
"@types/node-notifier": "^8.0.2",
|
|
40
|
+
"@types/prompts": "^2.4.4",
|
|
38
41
|
"@types/resolve-bin": "^0.4.1",
|
|
39
42
|
"@types/webpack-config-utils": "^2.3.1",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
41
|
-
"@typescript-eslint/parser": "^
|
|
42
|
-
"autoprefixer": "^10.4.
|
|
43
|
-
"babel-loader": "^9.1.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
44
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
45
|
+
"autoprefixer": "^10.4.15",
|
|
46
|
+
"babel-loader": "^9.1.3",
|
|
44
47
|
"babel-plugin-istanbul": "^6.1.1",
|
|
45
48
|
"babel-plugin-lodash": "^3.3.4",
|
|
46
|
-
"chalk": "^5.
|
|
49
|
+
"chalk": "^5.3.0",
|
|
47
50
|
"clean-webpack-plugin": "^4.0.0",
|
|
48
51
|
"columnify": "^1.6.0",
|
|
49
|
-
"commander": "^
|
|
52
|
+
"commander": "^11.0.0",
|
|
50
53
|
"copy-webpack-plugin": "^11.0.0",
|
|
51
|
-
"core-js": "^3.
|
|
52
|
-
"css-loader": "^6.
|
|
53
|
-
"css-minimizer-webpack-plugin": "^5.0.
|
|
54
|
-
"dotenv": "^16.
|
|
54
|
+
"core-js": "^3.32.2",
|
|
55
|
+
"css-loader": "^6.8.1",
|
|
56
|
+
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
57
|
+
"dotenv": "^16.3.1",
|
|
55
58
|
"dotenv-expand": "^10.0.0",
|
|
56
59
|
"escape-string-regexp": "^5.0.0",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-config-prettier": "^
|
|
59
|
-
"eslint-
|
|
60
|
+
"eslint": "^8.49.0",
|
|
61
|
+
"eslint-config-prettier": "^9.0.0",
|
|
62
|
+
"eslint-import-resolver-typescript": "^3.6.0",
|
|
63
|
+
"eslint-plugin-deprecation": "^1.5.0",
|
|
64
|
+
"eslint-plugin-import": "^2.28.1",
|
|
65
|
+
"eslint-plugin-markdownlint": "^0.5.0",
|
|
60
66
|
"eslint-plugin-promise": "^6.1.1",
|
|
61
|
-
"eslint-
|
|
62
|
-
"
|
|
67
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
68
|
+
"eslint-plugin-yml": "^1.9.0",
|
|
69
|
+
"eslint-webpack-plugin": "^4.0.1",
|
|
70
|
+
"execa": "^8.0.1",
|
|
63
71
|
"file-loader": "^6.2.0",
|
|
64
72
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
65
|
-
"glob": "^
|
|
73
|
+
"glob": "^10.3.4",
|
|
66
74
|
"html-loader": "^4.2.0",
|
|
67
|
-
"html-webpack-plugin": "^5.5.
|
|
75
|
+
"html-webpack-plugin": "^5.5.3",
|
|
68
76
|
"json-loader": "^0.5.7",
|
|
69
77
|
"lodash": "^4.17.21",
|
|
70
|
-
"mini-css-extract-plugin": "^2.7.
|
|
78
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
71
79
|
"node-notifier": "^10.0.1",
|
|
72
80
|
"portfinder": "^1.0.32",
|
|
73
|
-
"postcss": "^8.4.
|
|
74
|
-
"postcss-custom-properties": "^13.
|
|
75
|
-
"postcss-loader": "^7.
|
|
76
|
-
"prettier": "^
|
|
81
|
+
"postcss": "^8.4.29",
|
|
82
|
+
"postcss-custom-properties": "^13.3.0",
|
|
83
|
+
"postcss-loader": "^7.3.3",
|
|
84
|
+
"prettier": "^3.0.3",
|
|
85
|
+
"prompts": "^2.4.2",
|
|
77
86
|
"react-refresh": "^0.14.0",
|
|
78
87
|
"resolve-url-loader": "^5.0.0",
|
|
79
|
-
"sass": "^1.
|
|
80
|
-
"sass-loader": "^13.
|
|
88
|
+
"sass": "^1.66.1",
|
|
89
|
+
"sass-loader": "^13.3.2",
|
|
81
90
|
"source-map-loader": "^4.0.1",
|
|
82
91
|
"strip-indent": "^4.0.0",
|
|
83
|
-
"style-loader": "^3.3.
|
|
84
|
-
"tsconfig-paths-webpack-plugin": "^4.0
|
|
85
|
-
"tsup": "^
|
|
86
|
-
"typescript": "^5.
|
|
92
|
+
"style-loader": "^3.3.3",
|
|
93
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
94
|
+
"tsup": "^7.2.0",
|
|
95
|
+
"typescript": "^5.2.2",
|
|
87
96
|
"url-loader": "^4.1.1",
|
|
88
|
-
"webpack": "^5.
|
|
89
|
-
"webpack-cli": "^5.
|
|
97
|
+
"webpack": "^5.88.2",
|
|
98
|
+
"webpack-cli": "^5.1.4",
|
|
90
99
|
"webpack-config-utils": "^2.3.1",
|
|
91
|
-
"webpack-dev-server": "^4.
|
|
100
|
+
"webpack-dev-server": "^4.15.1",
|
|
92
101
|
"yaml-loader": "^0.8.0"
|
|
93
102
|
},
|
|
94
|
-
"
|
|
95
|
-
"babel-plugin-lodash": {
|
|
96
|
-
"@babel/types": "~7.20.0"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
103
|
+
"packageManager": "pnpm@8.7.5"
|
|
99
104
|
}
|
package/readme.html
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import {createCommand} from 'commander'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from 'lib/constants'
|
|
4
|
+
import {build, type BuildOptions} from 'commands/build'
|
|
5
|
+
import {deploy, type DeployOptions} from 'commands/deploy'
|
|
6
|
+
import {deployEmailConfig} from 'commands/deploy-email-config'
|
|
7
|
+
import {dev, type DevOptions} from 'commands/dev'
|
|
8
|
+
import {listDeployed, type ListDeployedOptions} from 'commands/list-deployed'
|
|
9
|
+
import {serve, type ServeOptions} from 'commands/serve'
|
|
10
|
+
import {DEFAULT_PORT, DEFAULT_TAG} from 'lib/constants'
|
|
11
11
|
import {logError} from 'lib/logging'
|
|
12
|
-
import
|
|
13
|
-
import {build, BuildOptions} from 'commands/build'
|
|
14
|
-
import {deploy, DeployOptions} from 'commands/deploy'
|
|
15
|
-
import {serve, ServeOptions} from 'commands/serve'
|
|
16
|
-
import {listDeployed, ListDeployedOptions} from 'commands/list-deployed'
|
|
17
|
-
import {
|
|
18
|
-
deployEmailConfig,
|
|
19
|
-
DeployEmailConfigOptions,
|
|
20
|
-
} from 'commands/deploy-email-config'
|
|
12
|
+
import pkg from '../package.json'
|
|
21
13
|
|
|
22
14
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
15
|
|
|
@@ -89,11 +81,6 @@ cli
|
|
|
89
81
|
'Tag which should be used for the deployment of the bundle',
|
|
90
82
|
DEFAULT_TAG,
|
|
91
83
|
)
|
|
92
|
-
.option(
|
|
93
|
-
'--profile <profile>',
|
|
94
|
-
'AWS profile which should be used for the deployment of the bundle',
|
|
95
|
-
DEFAULT_AWS_PROFILE,
|
|
96
|
-
)
|
|
97
84
|
.action(async (options: BuildOptions & ServeOptions & DeployOptions) => {
|
|
98
85
|
await build(options)
|
|
99
86
|
|
|
@@ -129,11 +116,6 @@ cli
|
|
|
129
116
|
'Tag which should be used for the deployment of the bundle',
|
|
130
117
|
DEFAULT_TAG,
|
|
131
118
|
)
|
|
132
|
-
.option(
|
|
133
|
-
'--profile <profile>',
|
|
134
|
-
'AWS profile which should be used for the deployment of the bundle',
|
|
135
|
-
DEFAULT_AWS_PROFILE,
|
|
136
|
-
)
|
|
137
119
|
.action(async (options: DeployOptions) => {
|
|
138
120
|
await deploy(options)
|
|
139
121
|
})
|
|
@@ -147,30 +129,15 @@ cli
|
|
|
147
129
|
'--config <config>',
|
|
148
130
|
'Configuration name (default: current customer configuration)',
|
|
149
131
|
)
|
|
150
|
-
.option(
|
|
151
|
-
'--profile <profile>',
|
|
152
|
-
'AWS profile which should be used for fetching deployments',
|
|
153
|
-
DEFAULT_AWS_PROFILE,
|
|
154
|
-
)
|
|
155
132
|
.action(async (options: ListDeployedOptions) => {
|
|
156
133
|
await listDeployed(options)
|
|
157
134
|
})
|
|
158
135
|
|
|
159
136
|
cli
|
|
160
137
|
.command('deploy-email-config')
|
|
161
|
-
.description(
|
|
162
|
-
.
|
|
163
|
-
|
|
164
|
-
'AWS S3 bucket where it should be deployed',
|
|
165
|
-
DEFAULT_AWS_S3_EMAIL_CONFIG_BUCKET,
|
|
166
|
-
)
|
|
167
|
-
.option(
|
|
168
|
-
'--profile <profile>',
|
|
169
|
-
'AWS profile which should be used for the deployment of email configuration',
|
|
170
|
-
DEFAULT_AWS_PROFILE,
|
|
171
|
-
)
|
|
172
|
-
.action(async (options: DeployEmailConfigOptions) => {
|
|
173
|
-
await deployEmailConfig(options)
|
|
138
|
+
.description("Deploy a widget's email configuration to AWS S3")
|
|
139
|
+
.action(async () => {
|
|
140
|
+
await deployEmailConfig()
|
|
174
141
|
})
|
|
175
142
|
|
|
176
143
|
///////////////////////////////////////////////////////////////////////////////
|
|
@@ -183,6 +150,7 @@ cli
|
|
|
183
150
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
184
151
|
logError(`\n${error.signalDescription}`)
|
|
185
152
|
} else {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
186
154
|
console.log('')
|
|
187
155
|
logError(error.stack)
|
|
188
156
|
}
|
package/src/commands/build.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import {type DeployOptions} from 'commands/deploy'
|
|
2
|
+
import {assertProfilesPresent, promptProfile} from 'lib/aws'
|
|
3
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
1
4
|
import {CORE_CONFIG_NAME} from 'lib/constants'
|
|
2
|
-
import {
|
|
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'
|
|
3
9
|
import {
|
|
4
10
|
getIfCoreFns,
|
|
5
11
|
getPaths,
|
|
@@ -7,12 +13,6 @@ import {
|
|
|
7
13
|
resolveBin,
|
|
8
14
|
resolveOwn,
|
|
9
15
|
} from 'lib/resolve'
|
|
10
|
-
import {applyEnv, assertEnvValid} from 'lib/env'
|
|
11
|
-
import {assertCrtExists} from 'lib/https'
|
|
12
|
-
import {logCommand, logTitle} from 'lib/logging'
|
|
13
|
-
import {notify} from 'lib/notifier'
|
|
14
|
-
import {halt, runCommandSync} from 'lib/command'
|
|
15
|
-
import {DeployOptions} from 'commands/deploy'
|
|
16
16
|
|
|
17
17
|
///////////////////////////////////////////////////////////////////////////////
|
|
18
18
|
|
|
@@ -33,15 +33,20 @@ export const build = async (
|
|
|
33
33
|
const {env} = options
|
|
34
34
|
|
|
35
35
|
assertOptionsValid(options)
|
|
36
|
+
assertProfilesPresent()
|
|
36
37
|
applyEnv(env)
|
|
37
38
|
|
|
39
|
+
if (options.deploy) {
|
|
40
|
+
options.profile = await promptProfile()
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
const flags = prepareFlags([], options).join(' ')
|
|
39
44
|
const {ifCore} = getIfCoreFns()
|
|
40
45
|
const paths = getPaths(ifCore)
|
|
41
46
|
const configName = ifCore(CORE_CONFIG_NAME, getWidgetUuid())
|
|
42
47
|
const title = ifCore(
|
|
43
48
|
'Building optimised (minified) bundle of Tamaro Core …',
|
|
44
|
-
`Building optimised (minified) bundle of
|
|
49
|
+
`Building optimised (minified) bundle of "${configName}" customer configuration …`,
|
|
45
50
|
)
|
|
46
51
|
|
|
47
52
|
const wpBin = resolveBin('webpack')
|
|
@@ -59,7 +64,8 @@ export const build = async (
|
|
|
59
64
|
|
|
60
65
|
/////////////////////////////////////////////////////////////////////////////
|
|
61
66
|
|
|
62
|
-
logTitle(`\nBundle for
|
|
67
|
+
logTitle(`\nBundle for "${configName}" customer configuration is done.`)
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
63
69
|
console.log(`Path: ${paths.appDist}\n`)
|
|
64
70
|
|
|
65
71
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -67,7 +73,7 @@ export const build = async (
|
|
|
67
73
|
process.on('exit', () => {
|
|
68
74
|
notify({
|
|
69
75
|
title: 'build',
|
|
70
|
-
message: `Bundle for
|
|
76
|
+
message: `Bundle for "${configName}" customer configuration is done.`,
|
|
71
77
|
})
|
|
72
78
|
})
|
|
73
79
|
}
|
|
@@ -75,22 +81,21 @@ export const build = async (
|
|
|
75
81
|
///////////////////////////////////////////////////////////////////////////////
|
|
76
82
|
|
|
77
83
|
const assertOptionsValid = (options: BuildOptions & DeployOptions) => {
|
|
78
|
-
const {localCore, https, deploy,
|
|
84
|
+
const {localCore, https, deploy, env} = options
|
|
79
85
|
const {ifCore} = getIfCoreFns()
|
|
80
86
|
|
|
81
87
|
if (ifCore() && localCore) {
|
|
82
|
-
halt('Flag
|
|
88
|
+
halt('Flag "--local-core" is redundant if running in Tamaro Core context.')
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
if (localCore && deploy) {
|
|
86
|
-
halt('Flags
|
|
92
|
+
halt('Flags "--local-core" and "--deploy" must not be used together.')
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
if (https) {
|
|
90
96
|
assertCrtExists()
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
assertProfileValid(profile)
|
|
94
99
|
assertEnvValid(env)
|
|
95
100
|
}
|
|
96
101
|
|
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
import {existsSync} from 'fs'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
assertProfilesPresent,
|
|
4
|
+
prepareFlags,
|
|
5
|
+
promptBucket,
|
|
6
|
+
promptProfile,
|
|
5
7
|
withAwsAuthenticate,
|
|
6
|
-
prepareFlags as prepareAwsFlags,
|
|
7
8
|
} from 'lib/aws'
|
|
9
|
+
import {halt, runCommandSync} from 'lib/command'
|
|
8
10
|
import {logCommand, logDataTable, logTitle} from 'lib/logging'
|
|
9
|
-
import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
|
|
10
11
|
import {notify} from 'lib/notifier'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
14
|
-
|
|
15
|
-
export type DeployEmailConfigOptions = AwsOptions & {
|
|
16
|
-
bucket: string
|
|
17
|
-
}
|
|
12
|
+
import {getIfCoreFns, getPaths, getWidgetUuid} from 'lib/resolve'
|
|
18
13
|
|
|
19
14
|
///////////////////////////////////////////////////////////////////////////////
|
|
20
15
|
|
|
21
|
-
export const deployEmailConfig = async (
|
|
22
|
-
options: DeployEmailConfigOptions,
|
|
23
|
-
): Promise<void> => {
|
|
16
|
+
export const deployEmailConfig = async (): Promise<void> => {
|
|
24
17
|
const {ifCore} = getIfCoreFns()
|
|
25
18
|
const paths = getPaths(ifCore)
|
|
26
19
|
const emailConfigPath = `${paths.app}/email-config`
|
|
27
20
|
|
|
28
|
-
assertOptionsValid(options)
|
|
29
21
|
assertIsNotCore()
|
|
30
22
|
assertEmailConfigPathExists(emailConfigPath)
|
|
23
|
+
assertProfilesPresent()
|
|
24
|
+
|
|
25
|
+
const profile = await promptProfile()
|
|
26
|
+
const bucket = await promptBucket()
|
|
31
27
|
|
|
32
|
-
const flags = prepareFlags([],
|
|
33
|
-
const {bucket} = options
|
|
28
|
+
const flags = prepareFlags([], {profile}).join(' ')
|
|
34
29
|
const configName = getWidgetUuid()
|
|
35
30
|
const deployUrl = `s3://${bucket}/${configName}`
|
|
36
31
|
|
|
@@ -41,12 +36,14 @@ export const deployEmailConfig = async (
|
|
|
41
36
|
${flags}
|
|
42
37
|
`
|
|
43
38
|
logTitle(
|
|
44
|
-
`Deploying email configuration for
|
|
39
|
+
`Deploying email configuration for "${configName}" customer configuration to AWS S3 …`,
|
|
45
40
|
)
|
|
46
41
|
logCommand(cmd)
|
|
47
42
|
|
|
48
43
|
try {
|
|
49
|
-
withAwsAuthenticate(() => runCommandSync(cmd, {stdout: 'inherit'}),
|
|
44
|
+
withAwsAuthenticate(() => runCommandSync(cmd, {stdout: 'inherit'}), {
|
|
45
|
+
profile,
|
|
46
|
+
})
|
|
50
47
|
} catch (error: any) {
|
|
51
48
|
halt(error.stderr)
|
|
52
49
|
}
|
|
@@ -54,7 +51,7 @@ export const deployEmailConfig = async (
|
|
|
54
51
|
/////////////////////////////////////////////////////////////////////////////
|
|
55
52
|
|
|
56
53
|
logTitle(
|
|
57
|
-
`Email configuration for
|
|
54
|
+
`Email configuration for "${configName}" customer configuration is deployed.`,
|
|
58
55
|
)
|
|
59
56
|
logDataTable({'Deploy URL:': deployUrl})
|
|
60
57
|
|
|
@@ -62,23 +59,14 @@ export const deployEmailConfig = async (
|
|
|
62
59
|
|
|
63
60
|
process.on('exit', () => {
|
|
64
61
|
notify({
|
|
65
|
-
title:
|
|
66
|
-
message: `Email configuration for
|
|
62
|
+
title: 'deploy-email-config',
|
|
63
|
+
message: `Email configuration for "${configName}" customer configuration is deployed.`,
|
|
67
64
|
})
|
|
68
65
|
})
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
///////////////////////////////////////////////////////////////////////////////
|
|
72
69
|
|
|
73
|
-
const assertOptionsValid = (options: DeployEmailConfigOptions) => {
|
|
74
|
-
const {bucket, profile} = options
|
|
75
|
-
|
|
76
|
-
assertBucketValid(bucket)
|
|
77
|
-
assertProfileValid(profile)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
81
|
-
|
|
82
70
|
const assertEmailConfigPathExists = (distPath: string) => {
|
|
83
71
|
if (!existsSync(distPath)) {
|
|
84
72
|
halt('Email config folder does not exists. Nothing to deploy.', 0)
|
|
@@ -87,18 +75,6 @@ const assertEmailConfigPathExists = (distPath: string) => {
|
|
|
87
75
|
|
|
88
76
|
///////////////////////////////////////////////////////////////////////////////
|
|
89
77
|
|
|
90
|
-
const assertBucketValid = (tag: string) => {
|
|
91
|
-
const regex = /^[a-zA-Z0-9-_]+$/
|
|
92
|
-
|
|
93
|
-
if (!regex.test(tag)) {
|
|
94
|
-
halt(
|
|
95
|
-
`Flag “--bucket” has forbidden format. Allowed format: ${regex.toString()}.`,
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
101
|
-
|
|
102
78
|
const assertIsNotCore = () => {
|
|
103
79
|
const {ifCore} = getIfCoreFns()
|
|
104
80
|
|
|
@@ -106,12 +82,3 @@ const assertIsNotCore = () => {
|
|
|
106
82
|
halt('You cannot deploy widget email configuration for Tamaro Core.')
|
|
107
83
|
}
|
|
108
84
|
}
|
|
109
|
-
|
|
110
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
111
|
-
|
|
112
|
-
const prepareFlags = (
|
|
113
|
-
flags: string[],
|
|
114
|
-
options: DeployEmailConfigOptions,
|
|
115
|
-
): string[] => {
|
|
116
|
-
return prepareAwsFlags(flags, options)
|
|
117
|
-
}
|