@pega/dx-component-builder-sdk 0.1.48 → 0.8.1
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/package.json +1 -1
- package/src/auth.js +726 -508
- package/src/tasks/authenticate/index.js +11 -1
- package/src/tasks/build/index.js +4 -4
- package/src/tasks/build-all/index.js +5 -5
- package/src/tasks/bundle/builderAngular/paths.js +1 -0
- package/src/tasks/bundle/builderAngular/webpack.config.js +8 -0
- package/src/tasks/bundle/builderAssociated/index.js +218 -0
- package/src/tasks/bundle/builderAssociated/modules.js +139 -0
- package/src/tasks/bundle/builderAssociated/paths.js +51 -0
- package/src/tasks/bundle/builderAssociated/webpack.config.js +337 -0
- package/src/tasks/bundle/builderReact/paths.js +2 -1
- package/src/tasks/bundle/builderReact/webpack.config.js +8 -0
- package/src/tasks/bundle/index.js +63 -5
- package/src/tasks/list/helper.js +2 -3
- package/src/tasks/override/index.js +17 -17
- package/src/tasks/publish/helper.js +3 -3
- package/src/tasks/publish/index.js +7 -7
- package/src/tasks/publish-all/helper.js +3 -3
- package/src/tasks/publish-all/index.js +9 -6
- package/src/util.js +15 -20
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
|
|
3
|
+
import webpack from 'webpack';
|
|
4
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
5
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
6
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
7
|
+
import getCSSModuleLocalIdent from 'react-dev-utils/getCSSModuleLocalIdent.js';
|
|
8
|
+
import ModuleNotFoundPlugin from 'react-dev-utils/ModuleNotFoundPlugin.js';
|
|
9
|
+
import CompressionPlugin from 'compression-webpack-plugin';
|
|
10
|
+
|
|
11
|
+
import paths from './paths.js';
|
|
12
|
+
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
|
|
15
|
+
// const appPackageJson = require(paths.appPackageJson);
|
|
16
|
+
|
|
17
|
+
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
|
18
|
+
|
|
19
|
+
const compressionBRConfObj = {
|
|
20
|
+
filename: '[path][base].br',
|
|
21
|
+
algorithm: 'brotliCompress',
|
|
22
|
+
test: /\.(js|css|html|svg|png|jpg|woff|woff2)$/,
|
|
23
|
+
compressionOptions: { level: 11 }
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/* For gzip use below */
|
|
27
|
+
const compressionGZConfObj = {
|
|
28
|
+
filename: '[path][base].gz',
|
|
29
|
+
algorithm: 'gzip',
|
|
30
|
+
test: /\.(js|css|html|svg|png|jpg|woff|woff2)$/,
|
|
31
|
+
compressionOptions: { level: 9 }
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let shouldUseSourceMap = process.env.SOURCE_MAP;
|
|
35
|
+
|
|
36
|
+
const imageInlineSizeLimit = Number.parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || '10000', 10);
|
|
37
|
+
|
|
38
|
+
// style files regex
|
|
39
|
+
const cssRegex = /\.css$/;
|
|
40
|
+
const cssModuleRegex = /\.module\.css$/;
|
|
41
|
+
const sassRegex = /\.(scss|sass)$/;
|
|
42
|
+
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
43
|
+
|
|
44
|
+
// This is the production and development configuration.
|
|
45
|
+
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
46
|
+
export default (
|
|
47
|
+
webpackEnv,
|
|
48
|
+
// eslint-disable-next-line no-unused-vars
|
|
49
|
+
{ inputFile, outputFile, componentKey, externals, globals, sourceMap, devBuild }
|
|
50
|
+
) => {
|
|
51
|
+
const isEnvDevelopment = webpackEnv === 'development' || devBuild;
|
|
52
|
+
const isEnvProduction = webpackEnv === 'production';
|
|
53
|
+
sourceMap = sourceMap === 'true';
|
|
54
|
+
shouldUseSourceMap = shouldUseSourceMap || sourceMap;
|
|
55
|
+
|
|
56
|
+
// common function to get style loaders
|
|
57
|
+
const getStyleLoaders = (cssOptions, preProcessor) => {
|
|
58
|
+
const loaders = [
|
|
59
|
+
isEnvProduction && {
|
|
60
|
+
loader: MiniCssExtractPlugin.loader
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
loader: require.resolve('css-loader'),
|
|
64
|
+
options: cssOptions
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
// Options for PostCSS as we reference these options twice
|
|
68
|
+
// Adds vendor prefixing based on your specified browser support in
|
|
69
|
+
// package.json
|
|
70
|
+
loader: require.resolve('postcss-loader'),
|
|
71
|
+
options: {
|
|
72
|
+
postcssOptions: {
|
|
73
|
+
plugins: [
|
|
74
|
+
[
|
|
75
|
+
'postcss-preset-env',
|
|
76
|
+
{
|
|
77
|
+
// Options
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
].filter(Boolean);
|
|
86
|
+
if (preProcessor) {
|
|
87
|
+
loaders.push(
|
|
88
|
+
{
|
|
89
|
+
loader: require.resolve('resolve-url-loader'),
|
|
90
|
+
options: {
|
|
91
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
92
|
+
root: paths.appSrc
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
loader: require.resolve(preProcessor),
|
|
97
|
+
options: {
|
|
98
|
+
sourceMap: true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return loaders;
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
mode: devBuild ? 'development' : 'production',
|
|
107
|
+
// Stop compilation early in production
|
|
108
|
+
bail: isEnvProduction,
|
|
109
|
+
// These are the "entry points" to our application.
|
|
110
|
+
// This means they will be the "root" imports that are included in JS bundle.
|
|
111
|
+
entry: inputFile,
|
|
112
|
+
devtool: devBuild ? 'eval-cheap-module-source-map' : false,
|
|
113
|
+
output: {
|
|
114
|
+
// The build folder.
|
|
115
|
+
path: paths.appBuild,
|
|
116
|
+
// There will be one main bundle, and one file per asynchronous chunk.
|
|
117
|
+
// In development, it does not produce real files.
|
|
118
|
+
filename: isEnvProduction
|
|
119
|
+
? `${componentKey}/${componentKey}.js`
|
|
120
|
+
: isEnvDevelopment && `${componentKey}/${componentKey}.js`,
|
|
121
|
+
chunkFilename: isEnvProduction
|
|
122
|
+
? `${componentKey}/js/[name].[contenthash:8].chunk.js`
|
|
123
|
+
: isEnvDevelopment && `${componentKey}/js/[name].chunk.js`,
|
|
124
|
+
library: {
|
|
125
|
+
name: componentKey,
|
|
126
|
+
type: 'umd',
|
|
127
|
+
export: 'default'
|
|
128
|
+
},
|
|
129
|
+
publicPath: ''
|
|
130
|
+
},
|
|
131
|
+
optimization: {
|
|
132
|
+
minimize: isEnvProduction,
|
|
133
|
+
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()]
|
|
134
|
+
},
|
|
135
|
+
resolve: {
|
|
136
|
+
plugins: [],
|
|
137
|
+
extensions: ['.tsx', '.ts', '.js']
|
|
138
|
+
},
|
|
139
|
+
resolveLoader: {
|
|
140
|
+
plugins: []
|
|
141
|
+
},
|
|
142
|
+
module: {
|
|
143
|
+
strictExportPresence: true,
|
|
144
|
+
rules: [
|
|
145
|
+
{
|
|
146
|
+
// "oneOf" will traverse all following loaders until one will
|
|
147
|
+
// match the requirements. When no loader matches it will fall
|
|
148
|
+
// back to the "file" loader at the end of the loader list.
|
|
149
|
+
oneOf: [
|
|
150
|
+
// TODO: Merge this config once `image/avif` is in the mime-db
|
|
151
|
+
// https://github.com/jshttp/mime-db
|
|
152
|
+
{
|
|
153
|
+
test: [/\.avif$/],
|
|
154
|
+
loader: require.resolve('url-loader'),
|
|
155
|
+
options: {
|
|
156
|
+
limit: imageInlineSizeLimit,
|
|
157
|
+
mimetype: 'image/avif',
|
|
158
|
+
name: `${componentKey}/media/[name].[hash:8].[ext]`
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
// "url" loader works like "file" loader except that it embeds assets
|
|
162
|
+
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
163
|
+
// A missing `test` is equivalent to a match.
|
|
164
|
+
{
|
|
165
|
+
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
|
|
166
|
+
loader: require.resolve('url-loader'),
|
|
167
|
+
options: {
|
|
168
|
+
limit: imageInlineSizeLimit,
|
|
169
|
+
name: `${componentKey}/media/[name].[hash:8].[ext]`
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
// Process application JS with TS-Loader.
|
|
173
|
+
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
|
|
174
|
+
{
|
|
175
|
+
test: /\.(js|mjs|jsx)$/,
|
|
176
|
+
include: paths.appSrc,
|
|
177
|
+
loader: 'ts-loader',
|
|
178
|
+
options: {
|
|
179
|
+
configFile: paths.appTsConfig
|
|
180
|
+
},
|
|
181
|
+
exclude: /node_modules/
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
{
|
|
185
|
+
test: /\.(ts|tsx)$/,
|
|
186
|
+
loader: 'ts-loader',
|
|
187
|
+
options: {
|
|
188
|
+
configFile: paths.appTsConfig
|
|
189
|
+
},
|
|
190
|
+
exclude: /node_modules/
|
|
191
|
+
},
|
|
192
|
+
// "postcss" loader applies autoprefixer to our CSS.
|
|
193
|
+
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
194
|
+
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
195
|
+
// In production, we use MiniCSSExtractPlugin to extract that CSS
|
|
196
|
+
// to a file, but in development "style" loader enables hot editing
|
|
197
|
+
// of CSS.
|
|
198
|
+
// By default we support CSS Modules with the extension .module.css
|
|
199
|
+
{
|
|
200
|
+
test: cssRegex,
|
|
201
|
+
exclude: cssModuleRegex,
|
|
202
|
+
use: getStyleLoaders({
|
|
203
|
+
importLoaders: 1,
|
|
204
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
|
|
205
|
+
}),
|
|
206
|
+
// Don't consider CSS imports dead code even if the
|
|
207
|
+
// containing package claims to have no side effects.
|
|
208
|
+
// Remove this when webpack adds a warning or an error for this.
|
|
209
|
+
// See https://github.com/webpack/webpack/issues/6571
|
|
210
|
+
sideEffects: true
|
|
211
|
+
},
|
|
212
|
+
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
|
|
213
|
+
// using the extension .module.css
|
|
214
|
+
{
|
|
215
|
+
test: cssModuleRegex,
|
|
216
|
+
use: getStyleLoaders({
|
|
217
|
+
importLoaders: 1,
|
|
218
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
219
|
+
modules: {
|
|
220
|
+
getLocalIdent: getCSSModuleLocalIdent
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
},
|
|
224
|
+
// Opt-in support for SASS (using .scss or .sass extensions).
|
|
225
|
+
// By default we support SASS Modules with the
|
|
226
|
+
// extensions .module.scss or .module.sass
|
|
227
|
+
{
|
|
228
|
+
test: sassRegex,
|
|
229
|
+
exclude: sassModuleRegex,
|
|
230
|
+
use: getStyleLoaders(
|
|
231
|
+
{
|
|
232
|
+
importLoaders: 3,
|
|
233
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment
|
|
234
|
+
},
|
|
235
|
+
'sass-loader'
|
|
236
|
+
),
|
|
237
|
+
// Don't consider CSS imports dead code even if the
|
|
238
|
+
// containing package claims to have no side effects.
|
|
239
|
+
// Remove this when webpack adds a warning or an error for this.
|
|
240
|
+
// See https://github.com/webpack/webpack/issues/6571
|
|
241
|
+
sideEffects: true
|
|
242
|
+
},
|
|
243
|
+
// Adds support for CSS Modules, but using SASS
|
|
244
|
+
// using the extension .module.scss or .module.sass
|
|
245
|
+
{
|
|
246
|
+
test: sassModuleRegex,
|
|
247
|
+
use: getStyleLoaders(
|
|
248
|
+
{
|
|
249
|
+
importLoaders: 3,
|
|
250
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
251
|
+
modules: {
|
|
252
|
+
getLocalIdent: getCSSModuleLocalIdent
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
'sass-loader'
|
|
256
|
+
)
|
|
257
|
+
},
|
|
258
|
+
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
259
|
+
// When you `import` an asset, you get its (virtual) filename.
|
|
260
|
+
// In production, they would get copied to the `build` folder.
|
|
261
|
+
// This loader doesn't use a "test" so it will catch all modules
|
|
262
|
+
// that fall through the other loaders.
|
|
263
|
+
{
|
|
264
|
+
loader: require.resolve('file-loader'),
|
|
265
|
+
// Exclude `js` files to keep "css" loader working as it injects
|
|
266
|
+
// its runtime that would otherwise be processed through "file" loader.
|
|
267
|
+
// Also exclude `html` and `json` extensions so they get processed
|
|
268
|
+
// by webpack's internal loaders.
|
|
269
|
+
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
|
270
|
+
options: {
|
|
271
|
+
name: `${componentKey}/media/[name].[hash:8].[ext]`
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// ** STOP ** Are you adding a new loader?
|
|
275
|
+
// Make sure to add the new loader(s) before the "file" loader.
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
plugins: [
|
|
281
|
+
// This gives some necessary context to module not found errors, such as
|
|
282
|
+
// the requesting resource.
|
|
283
|
+
new ModuleNotFoundPlugin(paths.appPath),
|
|
284
|
+
// Makes some environment variables available to the JS code, for example:
|
|
285
|
+
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
|
286
|
+
// It is absolutely essential that NODE_ENV is set to production
|
|
287
|
+
// during a production build.
|
|
288
|
+
// Otherwise React will be compiled in the very slow development mode.
|
|
289
|
+
isEnvProduction &&
|
|
290
|
+
new webpack.DefinePlugin({
|
|
291
|
+
PRODUCTION: JSON.stringify(true)
|
|
292
|
+
}),
|
|
293
|
+
isEnvProduction &&
|
|
294
|
+
new MiniCssExtractPlugin({
|
|
295
|
+
// Options similar to the same options in webpackOptions.output
|
|
296
|
+
// both options are optional
|
|
297
|
+
filename: `${componentKey}/css/${componentKey}.[contenthash:8].css`,
|
|
298
|
+
chunkFilename: `${componentKey}/css/${componentKey}.[contenthash:8].chunk.css`
|
|
299
|
+
}),
|
|
300
|
+
// Moment.js is an extremely popular library that bundles large locale files
|
|
301
|
+
// by default due to how webpack interprets its code. This is a practical
|
|
302
|
+
// solution that requires the user to opt into importing specific locales.
|
|
303
|
+
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
304
|
+
// You can remove this if you don't use Moment.js:
|
|
305
|
+
new webpack.IgnorePlugin({
|
|
306
|
+
resourceRegExp: /^\.\/locale$/,
|
|
307
|
+
contextRegExp: /moment$/
|
|
308
|
+
}),
|
|
309
|
+
/* Ignore cosmos icons */
|
|
310
|
+
new webpack.IgnorePlugin({
|
|
311
|
+
resourceRegExp: /^\.\/icons$/,
|
|
312
|
+
contextRegExp: /@pega\/cosmos-react-core\/lib\/components\/Icon$/
|
|
313
|
+
}),
|
|
314
|
+
|
|
315
|
+
/* Ignore cosmos icons - windows */
|
|
316
|
+
new webpack.IgnorePlugin({
|
|
317
|
+
resourceRegExp: /^\.\/icons$/,
|
|
318
|
+
contextRegExp: /@pega\\cosmos-react-core\\lib\\components\\Icon$/
|
|
319
|
+
}),
|
|
320
|
+
|
|
321
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
|
322
|
+
maxChunks: 1
|
|
323
|
+
}),
|
|
324
|
+
new webpack.optimize.MinChunkSizePlugin({
|
|
325
|
+
minChunkSize: 100000 // Minimum number of characters
|
|
326
|
+
}),
|
|
327
|
+
!devBuild && new CompressionPlugin(compressionBRConfObj)
|
|
328
|
+
|
|
329
|
+
/* Dont generate gzip file */
|
|
330
|
+
/* isEnvProduction && new CompressionPlugin(compressionGZConfObj) */
|
|
331
|
+
].filter(Boolean),
|
|
332
|
+
performance: {
|
|
333
|
+
hints: 'warning'
|
|
334
|
+
},
|
|
335
|
+
externals
|
|
336
|
+
};
|
|
337
|
+
};
|
|
@@ -36,6 +36,7 @@ const resolveModule = (resolveFn, filePath) => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// config after eject: we're in ./config/
|
|
39
|
+
// building a standard React component for react SDK, use same ts config as buid:dev
|
|
39
40
|
export default {
|
|
40
41
|
dotenv: resolveApp('.env'),
|
|
41
42
|
appPath: resolveApp('.'),
|
|
@@ -44,7 +45,7 @@ export default {
|
|
|
44
45
|
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
|
45
46
|
appPackageJson: resolveApp('package.json'),
|
|
46
47
|
appSrc: [resolveApp('src/components'), resolveApp('src/app/_components')],
|
|
47
|
-
appTsConfig: resolveApp('
|
|
48
|
+
appTsConfig: resolveApp('./tsconfig.build.json'),
|
|
48
49
|
appJsConfig: resolveApp('jsconfig.json'),
|
|
49
50
|
appNodeModules: resolveApp('node_modules')
|
|
50
51
|
};
|
|
@@ -255,6 +255,14 @@ export default (
|
|
|
255
255
|
'sass-loader'
|
|
256
256
|
)
|
|
257
257
|
},
|
|
258
|
+
{
|
|
259
|
+
test: /\.(d.ts)$/, /* latest react-sdk-components needs to ignore compiling .d.ts and .map files */
|
|
260
|
+
loader: 'null-loader',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
test: /\.(map)$/, /* latest react-sdk-components needs to ignore compiling .d.ts and .map files */
|
|
264
|
+
loader: 'null-loader',
|
|
265
|
+
},
|
|
258
266
|
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
259
267
|
// When you `import` an asset, you get its (virtual) filename.
|
|
260
268
|
// In production, they would get copied to the `build` folder.
|
|
@@ -7,9 +7,69 @@ import { getComponentDirectoryPath, getFramework, removeComponentPrefix } from '
|
|
|
7
7
|
|
|
8
8
|
import buildReactComponent from './builderReact/index.js';
|
|
9
9
|
import buildAngularComponent from './builderAngular/index.js';
|
|
10
|
+
import buildAssociatedComponent from './builderAssociated/index.js';
|
|
10
11
|
|
|
11
12
|
const extensions = ['ts', 'tsx', 'js', 'jsx'];
|
|
12
13
|
|
|
14
|
+
export const bundleAssociatedComponent = async (componentKey, sourceMap, devBuild, category = CATEGORY_CUSTOM) => {
|
|
15
|
+
const componentDirectory = await getComponentDirectoryPath(componentKey, category);
|
|
16
|
+
|
|
17
|
+
const idx = (
|
|
18
|
+
await Promise.all(
|
|
19
|
+
extensions.map(ext =>
|
|
20
|
+
stat(path.join(componentDirectory, `index.${ext}`))
|
|
21
|
+
.then(() => true)
|
|
22
|
+
.catch(() => false)
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
).findIndex(exists => exists);
|
|
26
|
+
|
|
27
|
+
if (idx === -1) throw new Error('Index file not found.');
|
|
28
|
+
|
|
29
|
+
// remove sub folder, component goes in dist directory without it
|
|
30
|
+
if (componentKey.indexOf("/") >=0) {
|
|
31
|
+
const arKey = componentKey.split("/");
|
|
32
|
+
componentKey = arKey[arKey.length - 1];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const inputFile = path.join(componentDirectory, `index.${extensions[idx]}`);
|
|
36
|
+
const outputFile = `${componentKey}.js`;
|
|
37
|
+
|
|
38
|
+
let buildConfig = {};
|
|
39
|
+
|
|
40
|
+
if (fs.existsSync(BUILD_CONFIG_JSON_FILENAME)) {
|
|
41
|
+
buildConfig = JSON.parse(fs.readFileSync(BUILD_CONFIG_JSON_FILENAME, 'utf8'));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let externals = buildConfig.externals || [];
|
|
45
|
+
externals = {
|
|
46
|
+
react: 'React',
|
|
47
|
+
'react-dom': 'ReactDOM',
|
|
48
|
+
PCore: 'PCore',
|
|
49
|
+
...buildConfig.externals
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let globals = buildConfig.globals || {};
|
|
53
|
+
|
|
54
|
+
const defaultGlobals = {
|
|
55
|
+
react: 'React',
|
|
56
|
+
'react-dom': 'ReactDOM',
|
|
57
|
+
PCore: 'PCore',
|
|
58
|
+
...buildConfig.globals
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
globals = { ...globals, ...defaultGlobals };
|
|
62
|
+
await buildAssociatedComponent({
|
|
63
|
+
inputFile,
|
|
64
|
+
outputFile,
|
|
65
|
+
componentKey,
|
|
66
|
+
externals,
|
|
67
|
+
globals,
|
|
68
|
+
sourceMap,
|
|
69
|
+
devBuild
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
13
73
|
export const bundleReactComponent = async (componentKey, sourceMap, devBuild, category = CATEGORY_CUSTOM) => {
|
|
14
74
|
const componentDirectory = await getComponentDirectoryPath(componentKey, category);
|
|
15
75
|
|
|
@@ -76,14 +136,14 @@ export const bundleAngularComponent = async (componentKey, sourceMap, devBuild,
|
|
|
76
136
|
|
|
77
137
|
const idx = (
|
|
78
138
|
await Promise.all(
|
|
79
|
-
extensions.map(ext =>
|
|
139
|
+
extensions.map(ext =>
|
|
80
140
|
stat(path.join(componentDirectory, `${componentKey}.component.${ext}`))
|
|
81
141
|
.then(() => true)
|
|
82
142
|
.catch(() => false)
|
|
83
143
|
)
|
|
84
144
|
)
|
|
85
145
|
).findIndex(exists => exists);
|
|
86
|
-
|
|
146
|
+
|
|
87
147
|
|
|
88
148
|
if (idx === -1) throw new Error('Index file not found.');
|
|
89
149
|
|
|
@@ -114,7 +174,7 @@ export const bundleAngularComponent = async (componentKey, sourceMap, devBuild,
|
|
|
114
174
|
PCore: 'PCore',
|
|
115
175
|
...buildConfig.globals
|
|
116
176
|
};
|
|
117
|
-
|
|
177
|
+
|
|
118
178
|
globals = { ...globals, ...defaultGlobals };
|
|
119
179
|
await buildAngularComponent({
|
|
120
180
|
inputFile,
|
|
@@ -126,5 +186,3 @@ export const bundleAngularComponent = async (componentKey, sourceMap, devBuild,
|
|
|
126
186
|
devBuild
|
|
127
187
|
});
|
|
128
188
|
};
|
|
129
|
-
|
|
130
|
-
|
package/src/tasks/list/helper.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import https from 'https';
|
|
3
2
|
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
5
|
|
|
7
6
|
import { LIST_COMPONENT_SERVICE_REST_ENDPOINT, TOKEN_PATH, COMPONENT_SCHEMA, CATEGORY_CUSTOM } from '../../constants.js';
|
|
8
|
-
import { constructCompleteUrl, getComponents, getPegaServerConfig } from '../../util.js';
|
|
7
|
+
import { constructCompleteUrl, getComponents, getPegaServerConfig, getHttpsAgent } from '../../util.js';
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
export const SOURCE_OF_COMPONENT_TYPES = {
|
|
@@ -75,7 +74,7 @@ export const getComponentsFromServer = async data => {
|
|
|
75
74
|
let status = 500;
|
|
76
75
|
fetch(url, {
|
|
77
76
|
method: 'GET',
|
|
78
|
-
agent:
|
|
77
|
+
agent: getHttpsAgent(defaultPegaServerConfig),
|
|
79
78
|
headers: {
|
|
80
79
|
Authorization: `${tokenType} ${accessToken}`
|
|
81
80
|
}
|
|
@@ -9,20 +9,20 @@ import chalk from 'chalk';
|
|
|
9
9
|
import { updateComponentMap } from '../map/map.js';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
checkPathAccess,
|
|
13
|
-
showVersion,
|
|
14
|
-
getPegaConfig,
|
|
15
|
-
convertIntoKebabCase,
|
|
12
|
+
checkPathAccess,
|
|
13
|
+
showVersion,
|
|
14
|
+
getPegaConfig,
|
|
15
|
+
convertIntoKebabCase,
|
|
16
16
|
getFramework,
|
|
17
17
|
getComponentDirectoryPath,
|
|
18
18
|
getComponents,
|
|
19
19
|
getComponentDefaults
|
|
20
20
|
} from '../../util.js';
|
|
21
21
|
|
|
22
|
-
import { COMPONENT_SCHEMA,
|
|
23
|
-
CATEGORY_OVERRIDE,
|
|
24
|
-
SDK_CONFIG_JSON_FILENAME,
|
|
25
|
-
DXCB_CONFIG,
|
|
22
|
+
import { COMPONENT_SCHEMA,
|
|
23
|
+
CATEGORY_OVERRIDE,
|
|
24
|
+
SDK_CONFIG_JSON_FILENAME,
|
|
25
|
+
DXCB_CONFIG,
|
|
26
26
|
DXCB_COMPONENT_DEFAULTS,
|
|
27
27
|
CUSTOM_TEMPLATES,
|
|
28
28
|
OVERRIDE_TEMPLATE_PATH,
|
|
@@ -94,7 +94,7 @@ const getListAvailableComponents = async (type) => {
|
|
|
94
94
|
fullList = COMPONENT_SCHEMA.overrideWCComponent[type];
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
let availList = [];
|
|
99
99
|
for (var el in fullList) {
|
|
100
100
|
|
|
@@ -121,7 +121,7 @@ const adjustAngularComponentName = (componentName) => {
|
|
|
121
121
|
if (componentName.indexOf("/") >= 0) {
|
|
122
122
|
componentName = componentName.split("/")[1];
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
|
|
126
126
|
return componentName;
|
|
127
127
|
}
|
|
@@ -163,7 +163,7 @@ const validateCompile = async (
|
|
|
163
163
|
|
|
164
164
|
if (pegaConfig[DXCB_CONFIG] &&
|
|
165
165
|
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES] &&
|
|
166
|
-
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH] &&
|
|
166
|
+
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH] &&
|
|
167
167
|
pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH] != "") {
|
|
168
168
|
templateParentDir = pegaConfig[DXCB_CONFIG][CUSTOM_TEMPLATES][OVERRIDE_TEMPLATE_PATH];
|
|
169
169
|
}
|
|
@@ -266,9 +266,9 @@ export default async options => {
|
|
|
266
266
|
if (options.params.length >= 5) {
|
|
267
267
|
let componentName = options.params[4];
|
|
268
268
|
let type;
|
|
269
|
-
|
|
269
|
+
|
|
270
270
|
if (promptType) type = promptType;
|
|
271
|
-
|
|
271
|
+
|
|
272
272
|
await validateCompile(
|
|
273
273
|
{
|
|
274
274
|
componentName,
|
|
@@ -338,16 +338,16 @@ export default async options => {
|
|
|
338
338
|
return widgetList.length > 0 && (answers.type === 'widget' || promptType === 'widget');
|
|
339
339
|
}
|
|
340
340
|
},
|
|
341
|
-
|
|
341
|
+
|
|
342
342
|
];
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
await inquirer.prompt(questions).then(async answers => {
|
|
345
345
|
let {
|
|
346
346
|
componentName,
|
|
347
347
|
type
|
|
348
348
|
} = answers;
|
|
349
349
|
if (promptType) type = promptType;
|
|
350
|
-
|
|
350
|
+
|
|
351
351
|
await validateCompile(
|
|
352
352
|
{
|
|
353
353
|
componentName,
|
|
@@ -356,7 +356,7 @@ export default async options => {
|
|
|
356
356
|
options
|
|
357
357
|
);
|
|
358
358
|
});
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import https from 'https';
|
|
4
3
|
|
|
5
4
|
import fetch from 'node-fetch';
|
|
6
5
|
import AdmZip from 'adm-zip';
|
|
@@ -14,7 +13,8 @@ import {
|
|
|
14
13
|
validateRulesetVersion,
|
|
15
14
|
getOptionsCategory,
|
|
16
15
|
getLocalComponentKeyFromConfig,
|
|
17
|
-
getFramework
|
|
16
|
+
getFramework,
|
|
17
|
+
getHttpsAgent
|
|
18
18
|
} from '../../util.js';
|
|
19
19
|
|
|
20
20
|
import { PUBLISH_COMPONENT_SERVICE_REST_ENDPOINT,
|
|
@@ -252,7 +252,7 @@ export const publishComponentToServer = async (data, doFetch = true) => {
|
|
|
252
252
|
let status = 500;
|
|
253
253
|
fetch(url, {
|
|
254
254
|
method: 'POST',
|
|
255
|
-
agent:
|
|
255
|
+
agent: getHttpsAgent(defaultPegaConfig),
|
|
256
256
|
headers: {
|
|
257
257
|
Authorization: `${tokenType} ${accessToken}`
|
|
258
258
|
},
|
|
@@ -4,7 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
|
|
5
5
|
import validate from '../validator/index.js';
|
|
6
6
|
import { getComponentDirectoryPath, showVersion, getOptionsCategory, getFramework, getLocalComponentKeyFromConfig, convertIntoKebabCase, convertIntoPascalCase } from '../../util.js';
|
|
7
|
-
import { bundleReactComponent, bundleAngularComponent} from '../bundle/index.js';
|
|
7
|
+
import { bundleReactComponent, bundleAngularComponent, bundleAssociatedComponent} from '../bundle/index.js';
|
|
8
8
|
import { updateComponentMap } from '../map/map.js';
|
|
9
9
|
import { lintComponent } from '../linter/index.js';
|
|
10
10
|
import { CATEGORY_CONSTELLATION, CATEGORY_CUSTOM } from '../../constants.js';
|
|
@@ -22,7 +22,7 @@ export default async options => {
|
|
|
22
22
|
showVersion();
|
|
23
23
|
|
|
24
24
|
const framework = await getFramework();
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
let componentKey;
|
|
27
27
|
let sourceMap;
|
|
28
28
|
let devBuild;
|
|
@@ -44,16 +44,16 @@ export default async options => {
|
|
|
44
44
|
} else {
|
|
45
45
|
const catQuestion = await getBuildCategory(options);
|
|
46
46
|
const catAnswers = await inquirer.prompt(catQuestion);
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
category = catAnswers.category;
|
|
49
49
|
if (category == null) {
|
|
50
50
|
category = getOptionsCategory(options);
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
const questions = await getPublishComponentQuestions(category);
|
|
54
54
|
const answers = await inquirer.prompt(questions);
|
|
55
55
|
({ componentKey, sourceMap, devBuild } = answers);
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
content = {
|
|
58
58
|
...answers
|
|
59
59
|
};
|
|
@@ -129,7 +129,7 @@ export default async options => {
|
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
title: `Bundle associated component ${sDevBuild}`,
|
|
132
|
-
task: async () => await
|
|
132
|
+
task: async () => await bundleAssociatedComponent(associatedComponentKey, sourceMap, devBuild, CATEGORY_CONSTELLATION),
|
|
133
133
|
skip: () => (options.skipBundle ? 'Skipped bundling component' : undefined)
|
|
134
134
|
},
|
|
135
135
|
{
|
|
@@ -199,7 +199,7 @@ export default async options => {
|
|
|
199
199
|
{
|
|
200
200
|
title: 'Publish component config',
|
|
201
201
|
task: async () => {
|
|
202
|
-
await publishComponentToServer(content);
|
|
202
|
+
await publishComponentToServer(content, doFetch);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|