@enact/cli 7.0.0 → 7.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/.travis.yml +1 -0
- package/CHANGELOG.md +18 -0
- package/bin/enact.js +1 -0
- package/commands/bootstrap.js +6 -5
- package/commands/clean.js +13 -16
- package/commands/create.js +7 -6
- package/commands/eject.js +11 -10
- package/commands/info.js +7 -6
- package/commands/license.js +4 -3
- package/commands/link.js +5 -4
- package/commands/lint.js +6 -5
- package/commands/pack.js +14 -10
- package/commands/serve.js +21 -16
- package/commands/template.js +16 -14
- package/commands/test.js +8 -7
- package/commands/transpile.js +6 -5
- package/config/eslintWebpackPluginConfig.js +1 -1
- package/config/jest/babelTransform.js +1 -0
- package/config/jest/cssTransform.js +2 -2
- package/config/jest/fileTransform.js +1 -1
- package/config/jest/setupTests.js +5 -4
- package/config/polyfills.js +1 -1
- package/config/webpack.config.js +125 -29
- package/docs/building-apps.md +1 -0
- package/docs/serving-apps.md +5 -0
- package/npm-shrinkwrap.json +5217 -4830
- package/package.json +41 -40
- package/eslint.config.js +0 -47
package/commands/template.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @remove-file-on-eject
|
|
2
|
+
/* eslint no-console: off, no-undef: off */
|
|
2
3
|
const os = require('os');
|
|
3
4
|
const path = require('path');
|
|
4
5
|
const url = require('url');
|
|
@@ -14,7 +15,7 @@ const TEMPLATE_DIR = path.join(process.env.APPDATA || os.homedir(), '.enact');
|
|
|
14
15
|
const INCLUDED = path.dirname(require.resolve('@enact/template-sandstone'));
|
|
15
16
|
const DEFAULT_LINK = path.join(TEMPLATE_DIR, 'default');
|
|
16
17
|
|
|
17
|
-
function displayHelp() {
|
|
18
|
+
function displayHelp () {
|
|
18
19
|
let e = 'node ' + path.relative(process.cwd(), __filename);
|
|
19
20
|
if (require.main !== module) e = 'enact template';
|
|
20
21
|
|
|
@@ -56,7 +57,7 @@ function displayHelp() {
|
|
|
56
57
|
process.exit(0);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function initTemplateArea() {
|
|
60
|
+
function initTemplateArea () {
|
|
60
61
|
if (!fs.existsSync(TEMPLATE_DIR)) {
|
|
61
62
|
fs.mkdirSync(TEMPLATE_DIR);
|
|
62
63
|
} else {
|
|
@@ -76,7 +77,7 @@ function initTemplateArea() {
|
|
|
76
77
|
return init.then(() => !fs.existsSync(DEFAULT_LINK) && doLink(sandstoneLink, 'default'));
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
function doInstall(target, name) {
|
|
80
|
+
function doInstall (target, name) {
|
|
80
81
|
const github = target.match(/^([a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38})\/([-_.\w]+)((?:#|@)?[-_.\w]+)?$/);
|
|
81
82
|
if (github) {
|
|
82
83
|
// If target is GitHub shorthand, resolve to full HTTPS URI
|
|
@@ -114,12 +115,12 @@ function doInstall(target, name) {
|
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
function normalizeName(name) {
|
|
118
|
+
function normalizeName (name) {
|
|
118
119
|
return name.replace(/(?:^enact-template-|^template-)/g, '');
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
// Clone Git repository using specific branch if desired
|
|
122
|
-
function installFromGit(target, name = normalizeName(path.basename(url.parse(target).pathname, '.git'))) {
|
|
123
|
+
function installFromGit (target, name = normalizeName(path.basename(url.parse(target).pathname, '.git'))) {
|
|
123
124
|
const git = target.match(/^(?:(^.*)#([\w\d-_.]+)?|(^.*))$/);
|
|
124
125
|
const args = ['clone', git[1] || git[3], name, '-c', 'advice.detachedHead=false'];
|
|
125
126
|
if (git[2]) args.splice(2, 0, '-b', git[2]);
|
|
@@ -137,7 +138,7 @@ function installFromGit(target, name = normalizeName(path.basename(url.parse(tar
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
// Copy directory files
|
|
140
|
-
function installFromLocal(target, name = normalizeName(path.basename(target))) {
|
|
141
|
+
function installFromLocal (target, name = normalizeName(path.basename(target))) {
|
|
141
142
|
const output = path.join(TEMPLATE_DIR, name);
|
|
142
143
|
fs.removeSync(output);
|
|
143
144
|
fs.ensureDirSync(output);
|
|
@@ -150,7 +151,7 @@ function installFromLocal(target, name = normalizeName(path.basename(target))) {
|
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
// Download and extract NPM package
|
|
153
|
-
function installFromNPM(target, name = normalizeName(path.basename(target).replace(/@.*$/g, ''))) {
|
|
154
|
+
function installFromNPM (target, name = normalizeName(path.basename(target).replace(/@.*$/g, ''))) {
|
|
154
155
|
const tempDir = path.join(os.tmpdir(), 'enact');
|
|
155
156
|
fs.removeSync(tempDir);
|
|
156
157
|
fs.ensureDirSync(tempDir);
|
|
@@ -182,7 +183,7 @@ function installFromNPM(target, name = normalizeName(path.basename(target).repla
|
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
function doLink(target, name = normalizeName(path.basename(path.resolve(target)))) {
|
|
186
|
+
function doLink (target, name = normalizeName(path.basename(path.resolve(target)))) {
|
|
186
187
|
const directory = path.resolve(target);
|
|
187
188
|
const prevCWD = process.cwd();
|
|
188
189
|
process.chdir(TEMPLATE_DIR);
|
|
@@ -199,7 +200,7 @@ function doLink(target, name = normalizeName(path.basename(path.resolve(target))
|
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
|
|
202
|
-
function doRemove(name) {
|
|
203
|
+
function doRemove (name) {
|
|
203
204
|
const output = path.join(TEMPLATE_DIR, name);
|
|
204
205
|
const isDefault = fs.existsSync(DEFAULT_LINK) && fs.realpathSync(output) === fs.realpathSync(DEFAULT_LINK);
|
|
205
206
|
if (!fs.existsSync(output)) return Promise.reject(new Error(`Unable to remove. Template "${name}" not found.`));
|
|
@@ -212,7 +213,7 @@ function doRemove(name) {
|
|
|
212
213
|
});
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
function doDefault(name) {
|
|
216
|
+
function doDefault (name) {
|
|
216
217
|
const all = fs.readdirSync(TEMPLATE_DIR).filter(t => t !== 'default');
|
|
217
218
|
let choice;
|
|
218
219
|
if (name && all.includes(name)) {
|
|
@@ -232,7 +233,7 @@ function doDefault(name) {
|
|
|
232
233
|
return choice.then(response => doLink(path.join(TEMPLATE_DIR, response.template), 'default'));
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
function doList() {
|
|
236
|
+
function doList () {
|
|
236
237
|
const realDefault = fs.realpathSync(DEFAULT_LINK);
|
|
237
238
|
const all = fs.readdirSync(TEMPLATE_DIR).filter(t => t !== 'default');
|
|
238
239
|
console.log(chalk.bold('Available Templates'));
|
|
@@ -250,12 +251,13 @@ function doList() {
|
|
|
250
251
|
});
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
function api({action, target, name} = {}) {
|
|
254
|
+
function api ({action, target, name} = {}) {
|
|
254
255
|
return initTemplateArea().then(() => {
|
|
255
256
|
let actionPromise;
|
|
256
257
|
|
|
257
|
-
if (['install', 'link', 'remove'].includes(action) && name === 'default')
|
|
258
|
+
if (['install', 'link', 'remove'].includes(action) && name === 'default') {
|
|
258
259
|
throw new Error('Template "default" name is reserved. ' + 'Use "enact template default" to modify it.');
|
|
260
|
+
}
|
|
259
261
|
|
|
260
262
|
switch (action) {
|
|
261
263
|
case 'install':
|
|
@@ -289,7 +291,7 @@ function api({action, target, name} = {}) {
|
|
|
289
291
|
});
|
|
290
292
|
}
|
|
291
293
|
|
|
292
|
-
function cli(args) {
|
|
294
|
+
function cli (args) {
|
|
293
295
|
import('chalk').then(({default: _chalk}) => {
|
|
294
296
|
chalk = _chalk;
|
|
295
297
|
const opts = minimist(args, {
|
package/commands/test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint no-console: off, no-undef: off */
|
|
1
2
|
/* eslint-env node, es6 */
|
|
2
3
|
// @remove-on-eject-begin
|
|
3
4
|
/**
|
|
@@ -26,7 +27,7 @@ process.on('unhandledRejection', err => {
|
|
|
26
27
|
throw err;
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
function isInGitRepository() {
|
|
30
|
+
function isInGitRepository () {
|
|
30
31
|
try {
|
|
31
32
|
execSync('git rev-parse --is-inside-work-tree', {stdio: 'ignore'});
|
|
32
33
|
return true;
|
|
@@ -35,7 +36,7 @@ function isInGitRepository() {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
function isInMercurialRepository() {
|
|
39
|
+
function isInMercurialRepository () {
|
|
39
40
|
try {
|
|
40
41
|
execSync('hg --cwd . root', {stdio: 'ignore'});
|
|
41
42
|
return true;
|
|
@@ -46,14 +47,14 @@ function isInMercurialRepository() {
|
|
|
46
47
|
|
|
47
48
|
// This is a very dirty workaround for https://github.com/facebook/jest/issues/5913.
|
|
48
49
|
// We're trying to resolve the environment ourselves because Jest does it incorrectly.
|
|
49
|
-
function resolveJestDefaultEnvironment(name) {
|
|
50
|
+
function resolveJestDefaultEnvironment (name) {
|
|
50
51
|
const jestDir = path.dirname(resolve.sync('jest', {basedir: __dirname}));
|
|
51
52
|
const jestCLIDir = path.dirname(resolve.sync('jest-cli', {basedir: jestDir}));
|
|
52
53
|
const jestConfigDir = path.dirname(resolve.sync('jest-config', {basedir: jestCLIDir}));
|
|
53
54
|
return resolve.sync(name, {basedir: jestConfigDir});
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
function testEnvironment(args) {
|
|
57
|
+
function testEnvironment (args) {
|
|
57
58
|
const env = (
|
|
58
59
|
args.reverse().find((curr, i, a) => curr.startsWith('--env=') || a[i + 1] === '--env') || 'jsdom'
|
|
59
60
|
).replace(/^--env=/, '');
|
|
@@ -74,7 +75,7 @@ function testEnvironment(args) {
|
|
|
74
75
|
return resolvedEnv || env;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function assignOverrides(config) {
|
|
78
|
+
function assignOverrides (config) {
|
|
78
79
|
const {meta} = packageRoot();
|
|
79
80
|
const overrides = Object.assign({}, meta.jest);
|
|
80
81
|
const supportedKeys = [
|
|
@@ -149,7 +150,7 @@ function assignOverrides(config) {
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
function api(args = []) {
|
|
153
|
+
function api (args = []) {
|
|
153
154
|
const config = require('../config/jest/jest.config');
|
|
154
155
|
|
|
155
156
|
// @TODO: readd dotenv parse support
|
|
@@ -171,7 +172,7 @@ function api(args = []) {
|
|
|
171
172
|
return jest.run(args);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
function cli(args) {
|
|
175
|
+
function cli (args) {
|
|
175
176
|
import('chalk').then(({default: _chalk}) => {
|
|
176
177
|
chalk = _chalk;
|
|
177
178
|
api(args).catch(() => {
|
package/commands/transpile.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @remove-file-on-eject
|
|
2
|
+
/* eslint no-console: off, no-undef: off */
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const babel = require('@babel/core');
|
|
4
5
|
const fs = require('fs-extra');
|
|
@@ -15,7 +16,7 @@ const babelConfig = path.join(__dirname, '..', 'config', 'babel.config.js');
|
|
|
15
16
|
const babelRename = {original: '^(\\.(?!.*\\bstyles\\b.*).*)\\.less$', replacement: '$1.css'};
|
|
16
17
|
const lessPlugins = [new LessPluginResolve({prefix: '~'}), new LessPluginRi(app.ri)];
|
|
17
18
|
|
|
18
|
-
function displayHelp() {
|
|
19
|
+
function displayHelp () {
|
|
19
20
|
let e = 'node ' + path.relative(process.cwd(), __filename);
|
|
20
21
|
if (require.main !== module) e = 'enact transpile';
|
|
21
22
|
|
|
@@ -33,7 +34,7 @@ function displayHelp() {
|
|
|
33
34
|
process.exit(0);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
function transpile(src, dest, plugins) {
|
|
37
|
+
function transpile (src, dest, plugins) {
|
|
37
38
|
return new Promise((resolve, reject) => {
|
|
38
39
|
babel.transformFile(src, {extends: babelConfig, plugins}, (err, result) => {
|
|
39
40
|
if (err) {
|
|
@@ -45,7 +46,7 @@ function transpile(src, dest, plugins) {
|
|
|
45
46
|
}).then(result => fs.writeFile(dest, result.code, {encoding: 'utf8'}));
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function lessc(src, dest) {
|
|
49
|
+
function lessc (src, dest) {
|
|
49
50
|
return less
|
|
50
51
|
.render(fs.readFileSync(src, {encoding: 'utf8'}), {
|
|
51
52
|
rewriteUrls: 'local',
|
|
@@ -56,7 +57,7 @@ function lessc(src, dest) {
|
|
|
56
57
|
.then(result => fs.writeFileSync(dest.replace(/\.less$/, '.css'), result.css, {encoding: 'utf8'}));
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function api({source = '.', output = './build', commonjs = true, ignore} = {}) {
|
|
60
|
+
function api ({source = '.', output = './build', commonjs = true, ignore} = {}) {
|
|
60
61
|
process.env.ES5 = 'true';
|
|
61
62
|
const babelPlugins = [
|
|
62
63
|
commonjs && require.resolve('@babel/plugin-transform-modules-commonjs'),
|
|
@@ -91,7 +92,7 @@ function api({source = '.', output = './build', commonjs = true, ignore} = {}) {
|
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
function cli(args) {
|
|
95
|
+
function cli (args) {
|
|
95
96
|
const opts = minimist(args, {
|
|
96
97
|
string: ['output', 'ignore'],
|
|
97
98
|
boolean: ['commonjs', 'help'],
|
|
@@ -15,7 +15,7 @@ const hasJsxRuntime = (() => {
|
|
|
15
15
|
}
|
|
16
16
|
})();
|
|
17
17
|
|
|
18
|
-
const loadedEnactConfig = process.env.FRAMEWORK ? eslintConfigEnactStrict : eslintConfigEnact;
|
|
18
|
+
const loadedEnactConfig = process.env.FRAMEWORK === true ? eslintConfigEnactStrict : eslintConfigEnact;
|
|
19
19
|
|
|
20
20
|
module.exports = [
|
|
21
21
|
...loadedEnactConfig,
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
17
17
|
|
|
18
18
|
module.exports = {
|
|
19
|
-
process() {
|
|
19
|
+
process () {
|
|
20
20
|
return {
|
|
21
21
|
code: 'module.exports = {};'
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
|
-
getCacheKey() {
|
|
24
|
+
getCacheKey () {
|
|
25
25
|
// The output is always the same.
|
|
26
26
|
return 'cssTransform';
|
|
27
27
|
}
|
|
@@ -18,7 +18,7 @@ const path = require('path');
|
|
|
18
18
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
process(src, filename) {
|
|
21
|
+
process (src, filename) {
|
|
22
22
|
const assetFilename = JSON.stringify(path.basename(filename));
|
|
23
23
|
return {
|
|
24
24
|
code: `module.exports = ${assetFilename};`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint no-console: off, no-undef: off */
|
|
1
2
|
/* eslint-env jest */
|
|
2
3
|
const fs = require('fs');
|
|
3
4
|
const path = require('path');
|
|
@@ -56,7 +57,7 @@ const ilibPaths = Object.keys(global).filter(k => /ILIB_[^_]+_PATH/.test(k));
|
|
|
56
57
|
const pkg = packageRoot();
|
|
57
58
|
const XHR = global.XMLHttpRequest;
|
|
58
59
|
class ILibXHR extends XHR {
|
|
59
|
-
open(method, url) {
|
|
60
|
+
open (method, url) {
|
|
60
61
|
if (ilibPaths.some(p => url.startsWith(global[p]))) {
|
|
61
62
|
this.send = () => {
|
|
62
63
|
try {
|
|
@@ -75,13 +76,13 @@ class ILibXHR extends XHR {
|
|
|
75
76
|
return super.open(...arguments);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
get readyState() {
|
|
79
|
+
get readyState () {
|
|
79
80
|
return typeof this.fileStatus !== 'undefined' ? XHR.DONE : super.readyState;
|
|
80
81
|
}
|
|
81
|
-
get status() {
|
|
82
|
+
get status () {
|
|
82
83
|
return typeof this.fileStatus !== 'undefined' ? this.fileStatus : super.status;
|
|
83
84
|
}
|
|
84
|
-
get responseText() {
|
|
85
|
+
get responseText () {
|
|
85
86
|
return typeof this.fileText !== 'undefined' ? this.fileText : super.responseText;
|
|
86
87
|
}
|
|
87
88
|
}
|
package/config/polyfills.js
CHANGED
package/config/webpack.config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint no-console: off, no-undef: off */
|
|
1
2
|
/* eslint-env node, es6 */
|
|
2
3
|
// @remove-on-eject-begin
|
|
3
4
|
/**
|
|
@@ -17,9 +18,9 @@ const path = require('path');
|
|
|
17
18
|
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
|
18
19
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
19
20
|
const ForkTsCheckerWebpackPlugin =
|
|
20
|
-
process.env.TSC_COMPILE_ON_ERROR === 'true'
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
process.env.TSC_COMPILE_ON_ERROR === 'true' ?
|
|
22
|
+
require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin') :
|
|
23
|
+
require('react-dev-utils/ForkTsCheckerWebpackPlugin');
|
|
23
24
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
24
25
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
25
26
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
@@ -41,12 +42,13 @@ const createEnvironmentHash = require('./createEnvironmentHash');
|
|
|
41
42
|
// This is the production and development configuration.
|
|
42
43
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
43
44
|
module.exports = function (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
env,
|
|
46
|
+
noLinting = false,
|
|
47
|
+
contentHash = false,
|
|
48
|
+
isomorphic = false,
|
|
49
|
+
noAnimation = false,
|
|
50
|
+
noSplitCSS = false,
|
|
51
|
+
ilibAdditionalResourcesPath
|
|
50
52
|
) {
|
|
51
53
|
process.chdir(app.context);
|
|
52
54
|
|
|
@@ -146,7 +148,98 @@ module.exports = function (
|
|
|
146
148
|
// the browserslist targets.
|
|
147
149
|
!useTailwind && require('postcss-normalize'),
|
|
148
150
|
// Resolution indepedence support
|
|
149
|
-
app.ri !== false && require('postcss-resolution-independence')(app.ri)
|
|
151
|
+
app.ri !== false && require('postcss-resolution-independence')(app.ri),
|
|
152
|
+
// Support importing JSON files with ~ alias - custom plugin (must run first)
|
|
153
|
+
{
|
|
154
|
+
postcssPlugin: 'postcss-import-json-tilde',
|
|
155
|
+
Once (root) {
|
|
156
|
+
// Process all @import-json rules with ~ prefix first, before other plugins
|
|
157
|
+
root.walkAtRules('import-json', atRule => {
|
|
158
|
+
let src = atRule.params.slice(1, -1); // Remove quotes
|
|
159
|
+
|
|
160
|
+
// Only handle ~ alias paths
|
|
161
|
+
if (src.startsWith('~')) {
|
|
162
|
+
const packagePath = src.substring(1); // Remove ~
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
// Use Node.js standard module resolution
|
|
166
|
+
// This mimics webpack's ~ alias behavior
|
|
167
|
+
const currentFileDir = path.dirname(atRule.source.input.file || '');
|
|
168
|
+
|
|
169
|
+
// Try to resolve the module using require.resolve
|
|
170
|
+
// This follows standard Node.js module resolution algorithm
|
|
171
|
+
let resolvedPath;
|
|
172
|
+
try {
|
|
173
|
+
// First try from current file's directory
|
|
174
|
+
resolvedPath = require.resolve(packagePath, {
|
|
175
|
+
paths: [currentFileDir]
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
// Fallback to current working directory
|
|
179
|
+
resolvedPath = require.resolve(packagePath, {
|
|
180
|
+
paths: [process.cwd()]
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Convert to relative path for the original plugin
|
|
185
|
+
const relativePath = path.relative(currentFileDir, resolvedPath);
|
|
186
|
+
atRule.params = `"${relativePath}"`;
|
|
187
|
+
} catch (error) {
|
|
188
|
+
// If resolution fails, try manual node_modules lookup
|
|
189
|
+
try {
|
|
190
|
+
let currentDir = path.dirname(
|
|
191
|
+
atRule.source.input.file || process.cwd()
|
|
192
|
+
);
|
|
193
|
+
let found = false;
|
|
194
|
+
|
|
195
|
+
// Walk up directories to find node_modules
|
|
196
|
+
while (currentDir !== path.parse(currentDir).root && !found) {
|
|
197
|
+
const moduleDir = path.join(
|
|
198
|
+
currentDir,
|
|
199
|
+
'node_modules',
|
|
200
|
+
packagePath
|
|
201
|
+
);
|
|
202
|
+
if (fs.existsSync(moduleDir)) {
|
|
203
|
+
const relativePath = path.relative(
|
|
204
|
+
path.dirname(atRule.source.input.file || ''),
|
|
205
|
+
moduleDir
|
|
206
|
+
);
|
|
207
|
+
atRule.params = `"${relativePath}"`;
|
|
208
|
+
found = true;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
currentDir = path.dirname(currentDir);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!found) {
|
|
215
|
+
console.warn(`Could not resolve module path: ${packagePath}`);
|
|
216
|
+
}
|
|
217
|
+
} catch (fallbackError) {
|
|
218
|
+
console.warn(
|
|
219
|
+
`Failed to resolve ${packagePath}:`,
|
|
220
|
+
fallbackError.message
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
// Support importing JSON files in CSS - original plugin (for non-~ paths)
|
|
229
|
+
[
|
|
230
|
+
'@daltontan/postcss-import-json',
|
|
231
|
+
{
|
|
232
|
+
map: (selector, value) => {
|
|
233
|
+
if (typeof value === 'object' && value !== null && value.$ref) {
|
|
234
|
+
const tokenPath = value.$ref.split('#/')[1];
|
|
235
|
+
const cssVariableName = '--' + tokenPath.replace(/\//g, '-');
|
|
236
|
+
|
|
237
|
+
return `var(${cssVariableName})`;
|
|
238
|
+
}
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
]
|
|
150
243
|
].filter(Boolean)
|
|
151
244
|
},
|
|
152
245
|
sourceMap: shouldUseSourceMap
|
|
@@ -187,8 +280,8 @@ module.exports = function (
|
|
|
187
280
|
mode: isEnvProduction ? 'production' : 'development',
|
|
188
281
|
// Don't attempt to continue if there are any errors.
|
|
189
282
|
bail: true,
|
|
190
|
-
// Webpack noise constrained to errors
|
|
191
|
-
stats: 'errors-
|
|
283
|
+
// Webpack noise constrained to errors only
|
|
284
|
+
stats: 'errors-only',
|
|
192
285
|
// Use source maps during development builds or when specified by GENERATE_SOURCEMAP
|
|
193
286
|
devtool: shouldUseSourceMap && (isEnvProduction ? 'source-map' : 'cheap-module-source-map'),
|
|
194
287
|
// These are the "entry points" to our application.
|
|
@@ -215,9 +308,9 @@ module.exports = function (
|
|
|
215
308
|
publicPath,
|
|
216
309
|
// Improved sourcemap path name mapping for system filepaths
|
|
217
310
|
devtoolModuleFilenameTemplate: info => {
|
|
218
|
-
let file = isEnvProduction
|
|
219
|
-
|
|
220
|
-
|
|
311
|
+
let file = isEnvProduction ?
|
|
312
|
+
path.relative(app.context, info.absoluteResourcePath) :
|
|
313
|
+
path.resolve(info.absoluteResourcePath);
|
|
221
314
|
file = file.replace(/\\/g, '/').replace(/\.\./g, '_');
|
|
222
315
|
const loader = info.allLoaders.match(/[^\\/]+-loader/);
|
|
223
316
|
if (info.resource.includes('.less') && loader) {
|
|
@@ -238,6 +331,7 @@ module.exports = function (
|
|
|
238
331
|
store: 'pack',
|
|
239
332
|
buildDependencies: {
|
|
240
333
|
defaultWebpack: ['webpack/lib/'],
|
|
334
|
+
// eslint-disable-next-line no-undef
|
|
241
335
|
config: [__filename],
|
|
242
336
|
tsconfig: useTypeScript ? ['tsconfig.json'] : []
|
|
243
337
|
}
|
|
@@ -267,9 +361,9 @@ module.exports = function (
|
|
|
267
361
|
symlinks: false,
|
|
268
362
|
// Backward compatibility for apps using new ilib references with old Enact
|
|
269
363
|
// and old apps referencing old iLib location with new Enact
|
|
270
|
-
alias: fs.existsSync(path.join(app.context, 'node_modules', '@enact', 'i18n', 'ilib'))
|
|
271
|
-
|
|
272
|
-
|
|
364
|
+
alias: fs.existsSync(path.join(app.context, 'node_modules', '@enact', 'i18n', 'ilib')) ?
|
|
365
|
+
Object.assign({ilib: '@enact/i18n/ilib'}, app.alias) :
|
|
366
|
+
Object.assign({'@enact/i18n/ilib': 'ilib'}, app.alias),
|
|
273
367
|
// Optional configuration for redirecting module requests.
|
|
274
368
|
fallback: app.resolveFallback
|
|
275
369
|
},
|
|
@@ -441,6 +535,7 @@ module.exports = function (
|
|
|
441
535
|
comments: false,
|
|
442
536
|
// Turned on because emoji and regex is not minified properly using default
|
|
443
537
|
// https://github.com/facebook/create-react-app/issues/2488
|
|
538
|
+
// eslint-disable-next-line camelcase
|
|
444
539
|
ascii_only: true
|
|
445
540
|
}
|
|
446
541
|
},
|
|
@@ -568,17 +663,18 @@ module.exports = function (
|
|
|
568
663
|
infrastructure: 'silent'
|
|
569
664
|
}
|
|
570
665
|
}),
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
666
|
+
!noLinting &&
|
|
667
|
+
new ESLintPlugin({
|
|
668
|
+
// Plugin options
|
|
669
|
+
configType: 'flat',
|
|
670
|
+
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
|
|
671
|
+
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
|
672
|
+
eslintPath: require.resolve('eslint'),
|
|
673
|
+
// @remove-on-eject-begin
|
|
674
|
+
overrideConfigFile: require.resolve('./eslintWebpackPluginConfig'),
|
|
675
|
+
// @remove-on-eject-end
|
|
676
|
+
cache: true
|
|
677
|
+
})
|
|
582
678
|
].filter(Boolean)
|
|
583
679
|
};
|
|
584
680
|
};
|
package/docs/building-apps.md
CHANGED
|
@@ -26,6 +26,7 @@ order: 4
|
|
|
26
26
|
(requires V8_MKSNAPSHOT set)
|
|
27
27
|
-m, --meta JSON to override package.json enact metadata
|
|
28
28
|
-c, --custom-skin Build with a custom skin
|
|
29
|
+
--no-linting Build without code linting
|
|
29
30
|
--no-animation Build without effects such as animation and shadow
|
|
30
31
|
--stats Output bundle analysis file
|
|
31
32
|
--verbose Verbose log build details
|
package/docs/serving-apps.md
CHANGED
|
@@ -10,7 +10,12 @@ order: 6
|
|
|
10
10
|
Options
|
|
11
11
|
-b, --browser Automatically open browser
|
|
12
12
|
-i, --host Server host IP address
|
|
13
|
+
-f, --fast Enables experimental frast refresh
|
|
13
14
|
-p, --port Server port number
|
|
15
|
+
-m, --meta JSON to override package.json enact metadata
|
|
16
|
+
--no-linting Build without code linting
|
|
17
|
+
-v, --version Display version information
|
|
18
|
+
-h, --help Display help information
|
|
14
19
|
```
|
|
15
20
|
The `enact serve` command (aliased as `npm run serve`) will build and host your project on **http://localhost:8080/**. The options allow you to customize the host IP and host port, which can also be overriden via `HOST` and `PORT` environment variable. While the `enact serve` is active, any changes to source code will trigger a rebuild and update any loaded browser windows.
|
|
16
21
|
|