@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/src/lib/env.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import {createRequire} from 'module'
|
|
2
2
|
import {basename} from 'path'
|
|
3
|
-
import glob from 'glob'
|
|
4
|
-
import type {IfUtilsFn} from 'webpack-config-utils'
|
|
5
|
-
import {expand as dotenvExpand} from 'dotenv-expand'
|
|
6
3
|
import {config as dotenvConfig} from 'dotenv'
|
|
4
|
+
import {expand as dotenvExpand} from 'dotenv-expand'
|
|
5
|
+
import {globSync} from 'glob'
|
|
7
6
|
import stripIndent from 'strip-indent'
|
|
8
|
-
import {
|
|
7
|
+
import type {IfUtilsFn} from 'webpack-config-utils'
|
|
9
8
|
import {halt} from 'lib/command'
|
|
9
|
+
import {getIfCoreFns, getPaths, getWidgetUuid, resolveApp} from 'lib/resolve'
|
|
10
10
|
|
|
11
11
|
///////////////////////////////////////////////////////////////////////////////
|
|
12
12
|
|
|
13
|
-
export type EnvVars =
|
|
14
|
-
[key: string]: string | undefined
|
|
15
|
-
}
|
|
13
|
+
export type EnvVars = Record<string, string | undefined>
|
|
16
14
|
|
|
17
15
|
///////////////////////////////////////////////////////////////////////////////
|
|
18
16
|
|
|
@@ -29,7 +27,9 @@ export const getEnvVars = (
|
|
|
29
27
|
) => {
|
|
30
28
|
const filePath = files.find((file) => basename(file) === '.env')
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
if (filePath) {
|
|
31
|
+
dotenvExpand(dotenvConfig({path: filePath}))
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
process.env.NODE_ENV ??= ifMin('production', 'development')
|
|
35
35
|
process.env.BABEL_ENV ??= ifMin('production', 'development')
|
|
@@ -41,9 +41,6 @@ export const getEnvVars = (
|
|
|
41
41
|
process.env.WEBPACK_UNIQUE_NAME ??= ifCore('RnwTamaroCore', 'RnwTamaro')
|
|
42
42
|
process.env.BUILD_DATE = new Date().toISOString()
|
|
43
43
|
process.env.PUBLIC_URL ??= ''
|
|
44
|
-
|
|
45
|
-
// HMR doesn't work in ie11, it breaks everything.
|
|
46
|
-
// If you want to run dev-server and test in ie11, set HMR_ENABLED to 'false'
|
|
47
44
|
process.env.HMR_ENABLED ??= ifMin('false', 'true')
|
|
48
45
|
|
|
49
46
|
if (ifCore()) {
|
|
@@ -61,7 +58,7 @@ export const getEnvVars = (
|
|
|
61
58
|
|
|
62
59
|
if (ifLocalCore()) {
|
|
63
60
|
const protocol = ifHttps() ? 'https' : 'http'
|
|
64
|
-
process.env.CORE_URL = `${protocol}://
|
|
61
|
+
process.env.CORE_URL = `${protocol}://localhost:1234/index.js`
|
|
65
62
|
} else {
|
|
66
63
|
let version = process.env.CORE_VERSION
|
|
67
64
|
version = version ? `@${version}` : ''
|
|
@@ -85,7 +82,12 @@ export const getEnvVars = (
|
|
|
85
82
|
'PRODUCT_NAME',
|
|
86
83
|
'PRODUCT_VERSION',
|
|
87
84
|
|
|
88
|
-
//
|
|
85
|
+
// config
|
|
86
|
+
'WIDGET_UUID',
|
|
87
|
+
'CORE_URL',
|
|
88
|
+
'CORE_VERSION', // should be explicitly specified in each config
|
|
89
|
+
|
|
90
|
+
// epik (obsolete since Tamaro v2.5.0)
|
|
89
91
|
'EPP_API_KEY_DEFAULT',
|
|
90
92
|
'EPP_API_URL_STAGE',
|
|
91
93
|
'EPP_API_URL_PROD',
|
|
@@ -97,16 +99,11 @@ export const getEnvVars = (
|
|
|
97
99
|
'EPMS_PROXY_URL_PROD',
|
|
98
100
|
'EPMS_TWINT_CHECKOUT_URL_STAGE',
|
|
99
101
|
'EPMS_TWINT_CHECKOUT_URL_PROD',
|
|
100
|
-
|
|
101
|
-
// config
|
|
102
|
-
'WIDGET_UUID',
|
|
103
|
-
'CORE_URL',
|
|
104
|
-
'CORE_VERSION', // must be explicitly specified in each config
|
|
105
102
|
]
|
|
106
103
|
|
|
107
104
|
// Collect all vars which names start from "PUBLIC_" or present in "varNames" array
|
|
108
105
|
const raw = Object.keys(process.env)
|
|
109
|
-
.filter((key) =>
|
|
106
|
+
.filter((key) => key.startsWith('PUBLIC_') || varNames.includes(key))
|
|
110
107
|
.reduce<EnvVars>((env, key) => {
|
|
111
108
|
env[key] = process.env[key]
|
|
112
109
|
|
|
@@ -127,35 +124,53 @@ export const getEnvVars = (
|
|
|
127
124
|
|
|
128
125
|
///////////////////////////////////////////////////////////////////////////////
|
|
129
126
|
|
|
130
|
-
export const assertEnvValid = (env
|
|
127
|
+
export const assertEnvValid = (env?: string) => {
|
|
131
128
|
const {ifCore} = getIfCoreFns()
|
|
132
129
|
const paths = getPaths(ifCore)
|
|
133
|
-
const files =
|
|
130
|
+
const files = globSync(paths.appEnv)
|
|
134
131
|
const envs = files
|
|
135
|
-
.map((file) => basename(file).replace(/^\.env
|
|
132
|
+
.map((file) => basename(file).replace(/^\.env\./, ''))
|
|
133
|
+
.map((file) => basename(file).replace(/^\.env$/, ''))
|
|
136
134
|
.filter((v) => !!v)
|
|
137
135
|
|
|
138
136
|
if (envs.length === 0) {
|
|
139
137
|
if (env) {
|
|
140
|
-
|
|
138
|
+
// There are no ".env.<env>" files, so we must ignore "--env" flag
|
|
139
|
+
// eslint-disable-next-line no-console
|
|
140
|
+
console.log('Flag "--env" is ignored.')
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
if (envs.length !== 0) {
|
|
145
145
|
if (!env) {
|
|
146
|
-
|
|
146
|
+
// There are some ".env.<env>" files, but no "--env" flag is specified,
|
|
147
|
+
// so we must require it
|
|
148
|
+
halt('Flag "--env" is required.')
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
if (!envs.includes(env)) {
|
|
151
|
+
if (env && !envs.includes(env)) {
|
|
152
|
+
// There are some ".env.<env>" files, but specified "--env" flag is incorrect
|
|
150
153
|
halt(
|
|
151
154
|
stripIndent(`
|
|
152
|
-
Flag
|
|
153
|
-
Available values are: ${envs.map((v) =>
|
|
155
|
+
Flag "--env" has wrong value.
|
|
156
|
+
Available values are: ${envs.map((v) => `"${v}"`).join(', ')}.
|
|
154
157
|
`),
|
|
155
158
|
)
|
|
156
159
|
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const applyEnv = (env?: string) => {
|
|
164
|
+
if (!env) {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const {ifCore} = getIfCoreFns()
|
|
169
|
+
const paths = getPaths(ifCore)
|
|
170
|
+
const files = globSync(paths.appEnv)
|
|
171
|
+
const filePath = files.find((file) => basename(file) === `.env.${env}`)
|
|
157
172
|
|
|
158
|
-
|
|
173
|
+
if (filePath) {
|
|
159
174
|
dotenvExpand(dotenvConfig({path: filePath}))
|
|
160
175
|
}
|
|
161
176
|
}
|
package/src/lib/https.ts
CHANGED
|
@@ -2,8 +2,8 @@ import {existsSync} from 'fs'
|
|
|
2
2
|
import {resolve} from 'path'
|
|
3
3
|
import stripIndent from 'strip-indent'
|
|
4
4
|
import {halt} from 'lib/command'
|
|
5
|
-
import {getIfCoreFns, getPaths} from 'lib/resolve'
|
|
6
5
|
import {HTTPS_CRT_FILE, HTTPS_KEY_FILE} from 'lib/constants'
|
|
6
|
+
import {getIfCoreFns, getPaths} from 'lib/resolve'
|
|
7
7
|
|
|
8
8
|
///////////////////////////////////////////////////////////////////////////////
|
|
9
9
|
|
|
@@ -19,7 +19,7 @@ export const assertCrtExists = () => {
|
|
|
19
19
|
|
|
20
20
|
halt(
|
|
21
21
|
stripIndent(`
|
|
22
|
-
Flag
|
|
22
|
+
Flag "--https" is used, but "${HTTPS_CRT_FILE}" and/or "${HTTPS_KEY_FILE}" files are not found.
|
|
23
23
|
You need to generate certificate first.
|
|
24
24
|
Check docs: https://unpkg.com/@raisenow/tamaro-cli/readme.html#/?id=use-transport-level-security-https
|
|
25
25
|
`),
|
package/src/lib/logging.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
|
-
import stripIndent from 'strip-indent'
|
|
3
2
|
import columnify from 'columnify'
|
|
3
|
+
import stripIndent from 'strip-indent'
|
|
4
4
|
|
|
5
5
|
///////////////////////////////////////////////////////////////////////////////
|
|
6
6
|
|
|
7
7
|
export const logTitle = (title: string) => {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
8
9
|
console.log(`${chalk.bold(title)}`)
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -12,6 +13,7 @@ export const logTitle = (title: string) => {
|
|
|
12
13
|
|
|
13
14
|
export const logError = (message?: string) => {
|
|
14
15
|
if (message) {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
15
17
|
console.log(chalk.red(message))
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -19,14 +21,17 @@ export const logError = (message?: string) => {
|
|
|
19
21
|
///////////////////////////////////////////////////////////////////////////////
|
|
20
22
|
|
|
21
23
|
export const logCommand = (cmd: string): void => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
22
25
|
console.log(`\n${chalk.dim(stripIndent(cmd).trim())}\n`)
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
///////////////////////////////////////////////////////////////////////////////
|
|
26
29
|
|
|
27
|
-
export const logDataTable = (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
export const logDataTable = (
|
|
31
|
+
data: Record<string, string | undefined>,
|
|
32
|
+
): void => {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
30
34
|
console.log(columnify(data, {showHeaders: false}))
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
31
36
|
console.log('')
|
|
32
37
|
}
|
package/src/lib/resolve.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {existsSync, realpathSync} from 'fs'
|
|
1
2
|
import {createRequire} from 'module'
|
|
2
3
|
import {basename, dirname, join, relative, resolve} from 'path'
|
|
3
|
-
import {existsSync, realpathSync} from 'fs'
|
|
4
|
-
import {getIfUtils, IfUtils, IfUtilsFn} from 'webpack-config-utils'
|
|
5
|
-
import {logError} from 'lib/logging'
|
|
6
|
-
import stripIndent from 'strip-indent'
|
|
7
4
|
import chalk from 'chalk'
|
|
5
|
+
import stripIndent from 'strip-indent'
|
|
6
|
+
import {getIfUtils, type IfUtils, type IfUtilsFn} from 'webpack-config-utils'
|
|
7
|
+
import {logError} from 'lib/logging'
|
|
8
8
|
|
|
9
9
|
///////////////////////////////////////////////////////////////////////////////
|
|
10
10
|
|
|
@@ -93,9 +93,7 @@ export const getPaths = (ifCore: IfUtilsFn) => {
|
|
|
93
93
|
|
|
94
94
|
///////////////////////////////////////////////////////////////////////////////
|
|
95
95
|
|
|
96
|
-
type Paths =
|
|
97
|
-
[key: string]: string | undefined
|
|
98
|
-
}
|
|
96
|
+
type Paths = Record<string, string | undefined>
|
|
99
97
|
|
|
100
98
|
export const getRelativePaths = (paths: Paths): Paths => {
|
|
101
99
|
const relativePaths: Paths = {}
|
package/src/webpack.config.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
import {existsSync} from 'fs'
|
|
1
2
|
import {createRequire} from 'module'
|
|
2
3
|
import {basename, dirname, resolve} from 'path'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {getIfUtils, removeEmpty} from 'webpack-config-utils'
|
|
6
|
-
import webpack from 'webpack'
|
|
7
|
-
import type {Configuration, RuleSetUseItem} from 'webpack'
|
|
8
|
-
import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin'
|
|
4
|
+
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
|
|
5
|
+
import StatoscopeWebpackPlugin from '@statoscope/webpack-plugin'
|
|
9
6
|
import {CleanWebpackPlugin} from 'clean-webpack-plugin'
|
|
10
|
-
import
|
|
7
|
+
import CopyPlugin from 'copy-webpack-plugin'
|
|
8
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
|
|
9
|
+
import ESLintPlugin from 'eslint-webpack-plugin'
|
|
11
10
|
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
|
|
12
|
-
import
|
|
11
|
+
import {globSync} from 'glob'
|
|
12
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
13
13
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
14
|
-
import
|
|
14
|
+
import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin'
|
|
15
|
+
import type {Configuration, RuleSetUseItem} from 'webpack'
|
|
16
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
17
|
+
import webpack from 'webpack'
|
|
18
|
+
import {getIfUtils, removeEmpty} from 'webpack-config-utils'
|
|
15
19
|
// Needed for webpack-dev-server types to be picked up correctly
|
|
16
20
|
import {} from 'webpack-dev-server'
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import StatoscopeWebpackPlugin from '@statoscope/webpack-plugin'
|
|
21
|
+
import {HTTPS_CRT_FILE, HTTPS_KEY_FILE} from 'lib/constants'
|
|
22
|
+
import {getEnvVars} from 'lib/env'
|
|
20
23
|
import {InterpolateHtmlPlugin} from 'lib/InterpolateHtmlPlugin'
|
|
24
|
+
import {logDataTable, logTitle} from 'lib/logging'
|
|
21
25
|
import {
|
|
22
26
|
extensions,
|
|
23
27
|
getIfCoreFns,
|
|
@@ -26,9 +30,6 @@ import {
|
|
|
26
30
|
moduleFileExtensions,
|
|
27
31
|
resolveApp,
|
|
28
32
|
} from 'lib/resolve'
|
|
29
|
-
import {getEnvVars} from 'lib/env'
|
|
30
|
-
import {logDataTable, logTitle} from 'lib/logging'
|
|
31
|
-
import {HTTPS_CRT_FILE, HTTPS_KEY_FILE} from 'lib/constants'
|
|
32
33
|
|
|
33
34
|
///////////////////////////////////////////////////////////////////////////////
|
|
34
35
|
|
|
@@ -38,15 +39,15 @@ const imageInlineSizeLimit = 0
|
|
|
38
39
|
|
|
39
40
|
///////////////////////////////////////////////////////////////////////////////
|
|
40
41
|
|
|
41
|
-
const getWebpackConfig =
|
|
42
|
+
const getWebpackConfig = (env: any): Configuration => {
|
|
42
43
|
const {ifMin, ifNotMin} = getIfUtils(env, ['min'])
|
|
43
44
|
const {ifAnalyze} = getIfUtils(env, ['analyze'])
|
|
44
45
|
const {ifHttps} = getIfUtils(env, ['https'])
|
|
45
46
|
const {ifLocalCore} = getIfUtils(env, ['localCore'])
|
|
46
47
|
const {ifCore} = getIfCoreFns()
|
|
47
48
|
const paths = getPaths(ifCore)
|
|
48
|
-
const appHtmlFiles =
|
|
49
|
-
const appEnvFiles =
|
|
49
|
+
const appHtmlFiles = globSync(paths.appHtml)
|
|
50
|
+
const appEnvFiles = globSync(paths.appEnv)
|
|
50
51
|
const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore, ifHttps)
|
|
51
52
|
const {ifHmr} = getIfUtils({hmr: process.env.HMR_ENABLED === 'true'}, ['hmr'])
|
|
52
53
|
const useTailwind =
|
|
@@ -84,7 +85,6 @@ const getWebpackConfig = async (env: any): Promise<Configuration> => {
|
|
|
84
85
|
plugins: removeEmpty([
|
|
85
86
|
useTailwind
|
|
86
87
|
? [
|
|
87
|
-
// eslint-disable-next-line node/no-missing-require
|
|
88
88
|
require.resolve('tailwindcss', {
|
|
89
89
|
paths: [paths.appNodeModules],
|
|
90
90
|
}),
|
|
@@ -387,6 +387,7 @@ const getWebpackConfig = async (env: any): Promise<Configuration> => {
|
|
|
387
387
|
contextRegExp: /moment$/,
|
|
388
388
|
}),
|
|
389
389
|
|
|
390
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
390
391
|
ifMin(new webpack.ids.HashedModuleIdsPlugin()), // todo: remove?
|
|
391
392
|
|
|
392
393
|
ifMin() && ifCore()
|
|
@@ -400,7 +401,7 @@ const getWebpackConfig = async (env: any): Promise<Configuration> => {
|
|
|
400
401
|
name: ifCore('tamaro-core', 'tamaro-customer-config'),
|
|
401
402
|
saveReportTo: 'reports/report.html',
|
|
402
403
|
saveStatsTo: 'reports/stats-[name]-[hash].json',
|
|
403
|
-
additionalStats:
|
|
404
|
+
additionalStats: globSync('reports/*.json'),
|
|
404
405
|
open: false,
|
|
405
406
|
})
|
|
406
407
|
: undefined,
|
package/tsconfig.json
CHANGED
package/.gitignore
DELETED