@raisenow/tamaro-cli 1.0.8 → 1.0.11
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 +1 -0
- package/{.eslintrc.js → .eslintrc.cjs} +2 -14
- package/.gitignore +4 -5
- package/.nvmrc +1 -1
- package/.prettierignore +1 -0
- package/{.prettierrc.js → .prettierrc.cjs} +0 -0
- package/README.md +229 -0
- package/dist/chunk-PIEFLCDU.js +144 -0
- package/dist/cli.js +486 -194
- package/dist/webpack.config.js +119 -227
- package/package.json +38 -47
- package/readme.html +1 -1
- package/src/cli.ts +109 -21
- package/src/commands/build.ts +99 -0
- package/src/commands/deploy-email-config.ts +115 -0
- package/src/commands/deploy.ts +163 -0
- package/src/commands/dev.ts +68 -0
- package/src/commands/list-deployed.ts +112 -0
- package/src/commands/serve.ts +53 -0
- package/src/lib/InterpolateHtmlPlugin.ts +10 -8
- package/src/lib/aws.ts +127 -0
- package/src/lib/command.ts +27 -0
- package/src/lib/constants.ts +7 -0
- package/src/lib/env.ts +102 -0
- package/src/lib/logging.ts +32 -0
- package/src/lib/notifier.ts +22 -0
- package/src/lib/resolve.ts +144 -0
- package/src/webpack.config.ts +36 -28
- package/tsconfig.json +1 -1
- package/readme.md +0 -201
- package/src/assets/rnw-logo.png +0 -0
- package/src/commands/build/index.ts +0 -42
- package/src/commands/deploy/index.ts +0 -24
- package/src/commands/dev/index.ts +0 -32
- package/src/commands/serve/index.ts +0 -12
- package/src/lib/helpers.ts +0 -279
- package/src/lib/polyfills.js +0 -8
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {commandSync} from 'execa'
|
|
2
|
-
import {logCommand, notify, resolveOwn} from 'lib/helpers'
|
|
3
|
-
import resolveBin from 'resolve-bin'
|
|
4
|
-
|
|
5
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
-
|
|
7
|
-
export type BuildOptions = {
|
|
8
|
-
localCore?: boolean
|
|
9
|
-
analyze?: boolean
|
|
10
|
-
deploy?: boolean
|
|
11
|
-
tag?: string
|
|
12
|
-
serve?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
16
|
-
|
|
17
|
-
const prepareBuildFlags = (options: BuildOptions): string => {
|
|
18
|
-
const {localCore, analyze} = options
|
|
19
|
-
let flags: string[] = []
|
|
20
|
-
|
|
21
|
-
flags = localCore ? [...flags, '--env localCore'] : flags
|
|
22
|
-
flags = analyze ? [...flags, '--env analyze'] : flags
|
|
23
|
-
|
|
24
|
-
return flags.join(' ')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
28
|
-
|
|
29
|
-
export const build = async (options: BuildOptions): Promise<void> => {
|
|
30
|
-
const flags = prepareBuildFlags(options)
|
|
31
|
-
|
|
32
|
-
const wpBin = resolveBin.sync('webpack')
|
|
33
|
-
const wpConfig = resolveOwn('dist/webpack.config.js')
|
|
34
|
-
const cmd = `${wpBin} --config ${wpConfig} --env min ${flags}`
|
|
35
|
-
logCommand(cmd)
|
|
36
|
-
commandSync(cmd, {stdio: 'inherit'})
|
|
37
|
-
|
|
38
|
-
notify({
|
|
39
|
-
title: '"build" command',
|
|
40
|
-
message: 'Process is done',
|
|
41
|
-
})
|
|
42
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {commandSync} from 'execa'
|
|
2
|
-
import {getIfCoreFns, getPaths, logCommand} from 'lib/helpers'
|
|
3
|
-
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
|
|
6
|
-
export type DeployOptions = {
|
|
7
|
-
tag?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
-
export const deploy = async (options: DeployOptions): Promise<void> => {
|
|
14
|
-
// todo: ensure build exists
|
|
15
|
-
// todo: handle "tag" option
|
|
16
|
-
// todo: implement
|
|
17
|
-
const {ifCore} = getIfCoreFns()
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
-
const paths = getPaths(ifCore)
|
|
20
|
-
|
|
21
|
-
const cmd = `echo Deploying to AWS is not implemented yet`
|
|
22
|
-
logCommand(cmd)
|
|
23
|
-
commandSync(cmd, {stdio: 'inherit'})
|
|
24
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {commandSync} from 'execa'
|
|
2
|
-
import {logCommand, resolveOwn} from 'lib/helpers'
|
|
3
|
-
import resolveBin from 'resolve-bin'
|
|
4
|
-
|
|
5
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
6
|
-
|
|
7
|
-
export type DevOptions = {
|
|
8
|
-
localCore?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
12
|
-
|
|
13
|
-
const prepareDevFlags = (options: DevOptions): string => {
|
|
14
|
-
const {localCore} = options
|
|
15
|
-
let flags: string[] = []
|
|
16
|
-
|
|
17
|
-
flags = localCore ? [...flags, '--env localCore'] : flags
|
|
18
|
-
|
|
19
|
-
return flags.join(' ')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
export const dev = async (options: DevOptions): Promise<void> => {
|
|
25
|
-
const flags = prepareDevFlags(options)
|
|
26
|
-
|
|
27
|
-
const wpBin = resolveBin.sync('webpack')
|
|
28
|
-
const wpConfig = resolveOwn('dist/webpack.config.js')
|
|
29
|
-
const cmd = `${wpBin} serve --config ${wpConfig} ${flags}`
|
|
30
|
-
logCommand(cmd)
|
|
31
|
-
commandSync(cmd, {stdio: 'inherit'})
|
|
32
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {commandSync} from 'execa'
|
|
2
|
-
import {getIfCoreFns, getPaths, logCommand} from 'lib/helpers'
|
|
3
|
-
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
|
|
6
|
-
export const serve = async (): Promise<void> => {
|
|
7
|
-
const {ifCore} = getIfCoreFns()
|
|
8
|
-
const paths = getPaths(ifCore)
|
|
9
|
-
const cmd = `npx -y http-server ${paths.appDist} --cors --port 1234`
|
|
10
|
-
logCommand(cmd)
|
|
11
|
-
commandSync(cmd, {stdio: 'inherit'})
|
|
12
|
-
}
|
package/src/lib/helpers.ts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import {basename, resolve} from 'path'
|
|
2
|
-
import {existsSync, realpathSync} from 'fs'
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
import {notify as nodeNotify} from 'node-notifier'
|
|
5
|
-
import {getIfUtils, IfUtils, IfUtilsFn} from 'webpack-config-utils'
|
|
6
|
-
import columnify from 'columnify'
|
|
7
|
-
import boxen from 'boxen'
|
|
8
|
-
import {expand as dotenvExpand} from 'dotenv-expand'
|
|
9
|
-
import {config as dotenvConfig} from 'dotenv'
|
|
10
|
-
import stripIndent from 'strip-indent'
|
|
11
|
-
|
|
12
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
13
|
-
|
|
14
|
-
export type ResolveFn = (relativePath: string) => string
|
|
15
|
-
|
|
16
|
-
export type EnvVars = {
|
|
17
|
-
[key: string]: string | undefined
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
21
|
-
// Supported packages
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
const TAMARO_CORE_PACKAGE_NAMES = ['@raisenow/tamaro-core', 'demo-tamaro-core']
|
|
25
|
-
const TAMARO_CONFIGURATIONS_PACKAGE_NAMES = [
|
|
26
|
-
'@raisenow/tamaro-configurations',
|
|
27
|
-
'demo-tamaro-configurations',
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
31
|
-
|
|
32
|
-
export const getIfCoreFns = (): IfUtils => {
|
|
33
|
-
const corePkgPath = resolveApp('package.json')
|
|
34
|
-
const configsPkgPath = resolveApp('../../package.json')
|
|
35
|
-
|
|
36
|
-
if (existsSync(corePkgPath)) {
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
38
|
-
const {name} = require(corePkgPath)
|
|
39
|
-
|
|
40
|
-
if (TAMARO_CORE_PACKAGE_NAMES.includes(name)) {
|
|
41
|
-
return getIfUtils({core: true}, ['core'])
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (existsSync(configsPkgPath)) {
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
47
|
-
const {name} = require(configsPkgPath)
|
|
48
|
-
|
|
49
|
-
if (TAMARO_CONFIGURATIONS_PACKAGE_NAMES.includes(name)) {
|
|
50
|
-
return getIfUtils({core: false}, ['core'])
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
console.error(
|
|
55
|
-
chalk.red(
|
|
56
|
-
stripIndent(`\
|
|
57
|
-
You must run "npx @raisenow/tamaro-cli" commands from:
|
|
58
|
-
1. Root of "${chalk.bold(TAMARO_CORE_PACKAGE_NAMES[0])}" package folder.
|
|
59
|
-
2. Root of particular customer configuration folder of "${chalk.bold(
|
|
60
|
-
TAMARO_CONFIGURATIONS_PACKAGE_NAMES[0],
|
|
61
|
-
)}" package.
|
|
62
|
-
You are currently in "${chalk.bold(realpathSync(process.cwd()))}".
|
|
63
|
-
`),
|
|
64
|
-
),
|
|
65
|
-
)
|
|
66
|
-
process.exit(0)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
70
|
-
// Extensions
|
|
71
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
72
|
-
|
|
73
|
-
export const moduleFileExtensions = ['ts', 'tsx', 'js', 'jsx']
|
|
74
|
-
export const extensions = moduleFileExtensions.map((v) => `.${v}`)
|
|
75
|
-
|
|
76
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
77
|
-
// Paths
|
|
78
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
79
|
-
|
|
80
|
-
export const resolveApp: ResolveFn = (relativePath) =>
|
|
81
|
-
resolve(realpathSync(process.cwd()), relativePath)
|
|
82
|
-
|
|
83
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
84
|
-
|
|
85
|
-
// __dirname is "dist" in runtime
|
|
86
|
-
export const resolveOwn: ResolveFn = (relativePath) =>
|
|
87
|
-
resolve(__dirname, '..', relativePath)
|
|
88
|
-
|
|
89
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
90
|
-
|
|
91
|
-
export const resolveModule = (resolveFn: ResolveFn, filePath: string) => {
|
|
92
|
-
const extension = moduleFileExtensions.find((extension) =>
|
|
93
|
-
existsSync(resolveFn(`${filePath}.${extension}`)),
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
if (extension) {
|
|
97
|
-
return resolveFn(`${filePath}.${extension}`)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return resolveFn(`${filePath}.js`)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
104
|
-
|
|
105
|
-
export const getWidgetUuid = () => basename(resolveApp('.'))
|
|
106
|
-
|
|
107
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
108
|
-
|
|
109
|
-
export const getPaths = (ifCore: IfUtilsFn) => {
|
|
110
|
-
return ifCore(
|
|
111
|
-
{
|
|
112
|
-
app: resolveApp('.'),
|
|
113
|
-
appEntry: resolveModule(resolveApp, 'src/index'),
|
|
114
|
-
appDist: resolveApp('dist'),
|
|
115
|
-
appNodeModules: resolveApp('node_modules'),
|
|
116
|
-
appTsConfig: resolveApp('tsconfig.json'),
|
|
117
|
-
appHtml: resolveApp('src/*.html'),
|
|
118
|
-
appEnv: resolveApp('.env'),
|
|
119
|
-
appTailwindConfig: resolveApp('tailwind.config.js'),
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
app: resolveApp('.'),
|
|
123
|
-
appEntry: resolveModule(resolveApp, 'widget'),
|
|
124
|
-
appDist: resolveApp(`../../dist/${getWidgetUuid()}`),
|
|
125
|
-
appNodeModules: resolveApp('../../node_modules'),
|
|
126
|
-
appTsConfig: resolveApp('tsconfig.json'),
|
|
127
|
-
appHtml: resolveApp('*.html'),
|
|
128
|
-
appEnv: resolveApp('.env'),
|
|
129
|
-
appTailwindConfig: undefined,
|
|
130
|
-
},
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
135
|
-
// Env vars
|
|
136
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
137
|
-
|
|
138
|
-
export const getEnvVars = (
|
|
139
|
-
filePath: string,
|
|
140
|
-
ifMin: IfUtilsFn,
|
|
141
|
-
ifCore: IfUtilsFn,
|
|
142
|
-
ifLocalCore: IfUtilsFn,
|
|
143
|
-
) => {
|
|
144
|
-
dotenvExpand(dotenvConfig({path: filePath}))
|
|
145
|
-
|
|
146
|
-
process.env.NODE_ENV ??= ifMin('production', 'development')
|
|
147
|
-
process.env.BABEL_ENV ??= ifMin('production', 'development')
|
|
148
|
-
process.env.EXPOSE_VAR ??= ifCore('rnw.tamaroCore', 'rnw.tamaro')
|
|
149
|
-
process.env.ELEMENT_ATTRIBUTE_DATA_WIDGET ??= ifCore(
|
|
150
|
-
'rnw-tamaro-core',
|
|
151
|
-
'rnw-tamaro',
|
|
152
|
-
)
|
|
153
|
-
process.env.WEBPACK_UNIQUE_NAME ??= ifCore('RnwTamaroCore', 'RnwTamaro')
|
|
154
|
-
|
|
155
|
-
// HMR doesn't work in ie11, it breaks everything.
|
|
156
|
-
// If you want to run dev-server and test in ie11, set HMR_ENABLED to 'false'
|
|
157
|
-
process.env.HMR_ENABLED ??= ifMin('false', 'true')
|
|
158
|
-
|
|
159
|
-
if (ifCore()) {
|
|
160
|
-
process.env.PRODUCT_NAME = 'tamaro'
|
|
161
|
-
|
|
162
|
-
const corePkgPath = resolveApp('package.json')
|
|
163
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
164
|
-
const {version} = require(corePkgPath)
|
|
165
|
-
|
|
166
|
-
process.env.PRODUCT_VERSION = version
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!ifCore()) {
|
|
170
|
-
process.env.WIDGET_UUID = getWidgetUuid()
|
|
171
|
-
|
|
172
|
-
if (ifLocalCore()) {
|
|
173
|
-
process.env.CORE_URL = `http://0.0.0.0:1234/index.js`
|
|
174
|
-
} else {
|
|
175
|
-
let version = process.env.CORE_VERSION
|
|
176
|
-
version = version ? `@${version}` : ''
|
|
177
|
-
|
|
178
|
-
process.env.CORE_URL ??= `https://cdn.jsdelivr.net/npm/@raisenow/tamaro-core${version}/dist/index.js`
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// var names which will be exposed along with "PUBLIC_*" var names
|
|
183
|
-
const varNames = [
|
|
184
|
-
// common
|
|
185
|
-
'NODE_ENV',
|
|
186
|
-
'BABEL_ENV',
|
|
187
|
-
'EXPOSE_VAR',
|
|
188
|
-
'ELEMENT_ATTRIBUTE_DATA_WIDGET',
|
|
189
|
-
'WEBPACK_UNIQUE_NAME',
|
|
190
|
-
|
|
191
|
-
// core
|
|
192
|
-
'PRODUCT_NAME',
|
|
193
|
-
'PRODUCT_VERSION',
|
|
194
|
-
|
|
195
|
-
// config
|
|
196
|
-
'WIDGET_UUID',
|
|
197
|
-
'CORE_URL',
|
|
198
|
-
'CORE_VERSION', // must be explicitly specified in each config
|
|
199
|
-
'IS_CREDIT_CARD_IFRAME',
|
|
200
|
-
|
|
201
|
-
// // todo: Environment variables for twint-qr-base
|
|
202
|
-
// 'EPMS_ENV',
|
|
203
|
-
// 'SOLUTION_CONFIG_BASE_URL',
|
|
204
|
-
// 'SHORT_ID_RESOLUTION_URL',
|
|
205
|
-
// 'HANDSHAKE_RESOLUTION_URL',
|
|
206
|
-
// 'TWINT_CHECKOUT_PAGE',
|
|
207
|
-
]
|
|
208
|
-
|
|
209
|
-
// Collect all vars which names start from "PUBLIC_" or present in "varNames" array
|
|
210
|
-
const raw = Object.keys(process.env)
|
|
211
|
-
.filter((key) => /^PUBLIC_/.test(key) || varNames.includes(key))
|
|
212
|
-
.reduce<EnvVars>((env, key) => {
|
|
213
|
-
env[key] = process.env[key]
|
|
214
|
-
|
|
215
|
-
return env
|
|
216
|
-
}, {})
|
|
217
|
-
|
|
218
|
-
// Stringify all values so we can feed into webpack DefinePlugin
|
|
219
|
-
const stringified = {
|
|
220
|
-
'process.env': Object.keys(raw).reduce<EnvVars>((env, key) => {
|
|
221
|
-
env[key] = JSON.stringify(raw[key])
|
|
222
|
-
|
|
223
|
-
return env
|
|
224
|
-
}, {}),
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return {raw, stringified}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
231
|
-
// Other
|
|
232
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
233
|
-
|
|
234
|
-
export const logCommand = (...args: any[]): void => {
|
|
235
|
-
console.log(chalk.dim(...args))
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
239
|
-
|
|
240
|
-
// Log data into console as a table
|
|
241
|
-
export const logDataTable = (
|
|
242
|
-
vars: {[key: string]: string | undefined},
|
|
243
|
-
title: string,
|
|
244
|
-
): void => {
|
|
245
|
-
const boxTitle = chalk.bold(`${title}:\n`)
|
|
246
|
-
const boxTable = columnify(vars, {showHeaders: false})
|
|
247
|
-
|
|
248
|
-
// eslint-disable-next-line no-console
|
|
249
|
-
console.log(
|
|
250
|
-
boxen(`${boxTitle}\n${boxTable}`, {
|
|
251
|
-
margin: 0,
|
|
252
|
-
padding: {
|
|
253
|
-
top: 0,
|
|
254
|
-
right: 1,
|
|
255
|
-
bottom: 0,
|
|
256
|
-
left: 1,
|
|
257
|
-
},
|
|
258
|
-
borderColor: 'green',
|
|
259
|
-
}),
|
|
260
|
-
)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
264
|
-
|
|
265
|
-
export type NotifyArgs = {
|
|
266
|
-
title: string
|
|
267
|
-
message: string
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export const notify = (args: NotifyArgs): void => {
|
|
271
|
-
const {title, message} = args
|
|
272
|
-
|
|
273
|
-
nodeNotify({
|
|
274
|
-
title,
|
|
275
|
-
message,
|
|
276
|
-
contentImage: resolveOwn('src/assets/rnw-logo.png'),
|
|
277
|
-
sound: 'Funk',
|
|
278
|
-
})
|
|
279
|
-
}
|
package/src/lib/polyfills.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import 'core-js/stable'
|
|
2
|
-
// import 'core-js/features/promise'
|
|
3
|
-
// import 'core-js/features/symbol'
|
|
4
|
-
// import 'core-js/features/object/assign'
|
|
5
|
-
// import 'core-js/features/string/match-all'
|
|
6
|
-
import 'element-closest/browser.js'
|
|
7
|
-
import 'unfetch/polyfill'
|
|
8
|
-
import 'current-script-polyfill'
|