@eui/cli 21.0.5-snapshot-1771153461655 → 21.0.5-snapshot-1771237470720

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/README.md CHANGED
@@ -1,26 +1,84 @@
1
- # eUI platform
1
+ # @eui/cli
2
2
 
3
- ## Pre-requisites
3
+ Command-line interface for scaffolding and managing eUI applications.
4
4
 
5
- **NodeJS 20.19.x**
5
+ ## Installation
6
6
 
7
- **Yarn**
7
+ ```sh
8
+ npm install -g @eui/cli
9
+ ```
8
10
 
11
+ ## Usage with npx
9
12
 
10
- ## Quickstart
13
+ Run without installing globally:
14
+
15
+ ```sh
16
+ npx @eui/cli new
17
+ ```
11
18
 
12
- The entry point of eUI is the @eui/cli package, this will help you scaffold an eUI app of your choice :
19
+ ## Usage
13
20
 
14
- ### Install @eui/cli
21
+ ### Generate a new application
15
22
 
16
23
  ```sh
17
- npm install -g @eui/cli@latest
24
+ eui-cli new
18
25
  ```
19
26
 
20
- ### Generate an app
27
+ Or simply:
28
+
21
29
  ```sh
22
- cd <your-root-dev-folder>
23
- mkdir myApp
24
- cd myApp
25
30
  eui-cli
26
31
  ```
32
+
33
+ ### Build application
34
+
35
+ ```sh
36
+ eui-cli build-app [options]
37
+ ```
38
+
39
+ Options:
40
+ - `--skipLint` - Skip linting step
41
+ - `--skipTest` - Skip testing step
42
+ - `--skipCompile` - Skip compilation step
43
+ - `-c, --configuration <config>` - Angular build configuration
44
+ - `--baseHref <href>` - Base href for the application
45
+ - `--statsJson` - Generate stats.json file
46
+ - `--sourceMap` - Generate source maps
47
+
48
+ ### Serve application
49
+
50
+ ```sh
51
+ eui-cli serve-app [options]
52
+ ```
53
+
54
+ Options:
55
+ - `-c, --configuration <config>` - Angular build configuration
56
+ - `-p, --port <port>` - Port number (default: 4200)
57
+ - `-h, --host <host>` - Host to serve on
58
+ - `--proxyConfig <path>` - Path to proxy configuration file
59
+ - `--open` - Open browser automatically
60
+
61
+ ### Lint application
62
+
63
+ ```sh
64
+ eui-cli lint-app
65
+ ```
66
+
67
+ ### Generate SVG sprite
68
+
69
+ ```sh
70
+ eui-cli generate-sprite -i <input-folder> -o <output-file>
71
+ ```
72
+
73
+ Options:
74
+ - `-i, --inFolder <path>` - Input folder containing SVG files (required)
75
+ - `-o, --outFile <filename>` - Output sprite filename with .svg extension (required)
76
+
77
+ ## Requirements
78
+
79
+ - Node.js 24.x or higher
80
+ - npm or yarn
81
+
82
+ ## License
83
+
84
+ EUPL-1.1
package/bin/eui-cli.js CHANGED
@@ -1,62 +1,119 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const spawn = require('cross-spawn');
4
- const args = process.argv.slice(2);
5
-
6
- const scriptIndex = args.findIndex(
7
- (x) =>
8
- x === '' ||
9
- x === undefined ||
10
- x === 'new' ||
11
- x === 'build-app' ||
12
- x === 'serve-app' ||
13
- x === 'lint-app' ||
14
- x === 'inject-config-app' ||
15
- x === 'generate-sprite'
16
- );
17
- const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
18
- const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
19
-
20
- switch (script) {
21
- case '':
22
- case undefined:
23
- case 'new':
24
- case 'build-app':
25
- case 'serve-app':
26
- case 'lint-app':
27
- case 'inject-config-app':
28
- case 'generate-sprite': {
29
- let genScript = script;
30
- if (script === '' || script === undefined) {
31
- genScript = 'new';
32
- }
33
- const result = spawn.sync(
34
- 'node',
35
- nodeArgs
36
- .concat(require.resolve('./scripts/' + genScript))
37
- .concat(args.slice(scriptIndex + 1)),
38
- { stdio: 'inherit' }
39
- );
40
- if (result.signal) {
41
- if (result.signal === 'SIGKILL') {
42
- console.log(
43
- 'The build failed because the process exited too early. '+
44
- 'This probably means the system ran out of memory or someone called ' +
45
- '`kill -9` on the process.'
46
- );
47
- } else if(result.signal === 'SIGTERM') {
48
- console.log(
49
- 'The build failed because the process exited too early. ' +
50
- 'Someone might have called `kill` or `killall`, or the system could ' +
51
- 'be shutting down.'
52
- )
53
- }
54
- process.exit(1);
55
- }
56
- process.exit(result.status);
57
- break;
3
+ const { Command } = require('commander');
4
+ const config = require('../lib/config');
5
+
6
+ const program = new Command();
7
+
8
+ program
9
+ .name('eui-cli')
10
+ .description('eUI CLI app generator & tools')
11
+ .version(config.version, '-v, --version', 'output the current version');
12
+
13
+ function buildProcessArgv(options, command) {
14
+ const scriptArgs = [];
15
+
16
+ Object.keys(options).forEach(key => {
17
+ if (key !== 'parent' && options[key] !== undefined) {
18
+ const value = options[key];
19
+ if (value === true) {
20
+ scriptArgs.push(`--${key}`);
21
+ } else if (value !== false) {
22
+ scriptArgs.push(`--${key}=${value}`);
23
+ }
58
24
  }
59
- default:
60
- console.log('Unknown script "' + script + '".');
61
- break;
25
+ });
26
+
27
+ if (command && command.args) {
28
+ scriptArgs.push(...command.args);
29
+ }
30
+
31
+ process.argv = ['node', 'eui-cli', ...scriptArgs];
62
32
  }
33
+
34
+ async function handleCommand(scriptPath, options, command) {
35
+ buildProcessArgv(options, command);
36
+
37
+ try {
38
+ const script = require(scriptPath);
39
+ // If script exports a function, call it; otherwise it's a promise
40
+ if (typeof script === 'function') {
41
+ await script();
42
+ } else {
43
+ await script;
44
+ }
45
+ } catch (error) {
46
+ console.error(error);
47
+ process.exit(1);
48
+ }
49
+ }
50
+
51
+ program
52
+ .command('new', { isDefault: true })
53
+ .description('Generate a new eUI application')
54
+ .option('-c, --config <path>', 'Path to configuration file')
55
+ .option('-t, --targetPath <path>', 'Target path for the generated application')
56
+ .action((options, command) => handleCommand('./scripts/new', options, command));
57
+
58
+ program
59
+ .command('build-app')
60
+ .description('Build the eUI application')
61
+ .option('--skipLint', 'Skip linting step')
62
+ .option('--skipTest', 'Skip testing step')
63
+ .option('--skipCompile', 'Skip compilation step')
64
+ .option('-c, --configuration <config>', 'Angular build configuration')
65
+ .option('--baseHref <href>', 'Base href for the application')
66
+ .option('--servePath <path>', 'Serve path for the application')
67
+ .option('-w, --watch', 'Enable watch mode for tests')
68
+ .option('--dryRun', 'Run in dry-run mode')
69
+ .option('--maxSpaceSize', 'Use increased memory allocation')
70
+ .option('--statsJson', 'Generate stats.json file')
71
+ .option('--ci', 'Enable CI mode')
72
+ .option('--deployUrl <url>', 'Deploy URL for the application')
73
+ .option('--sourceMap', 'Generate source maps')
74
+ .option('--configEnvTarget <target>', 'Environment target for configuration')
75
+ .option('--project <name>', 'Project name')
76
+ .option('-d, --debug', 'Enable debug mode')
77
+ .action((options, command) => handleCommand('./scripts/build-app', options, command));
78
+
79
+ program
80
+ .command('serve-app')
81
+ .description('Serve the eUI application')
82
+ .option('-c, --configuration <config>', 'Angular build configuration')
83
+ .option('--baseHref <href>', 'Base href for the application')
84
+ .option('--servePath <path>', 'Serve path for the application')
85
+ .option('-h, --host <host>', 'Host to serve on')
86
+ .option('--proxyConfig <path>', 'Path to proxy configuration file')
87
+ .option('--maxSpaceSize', 'Use increased memory allocation')
88
+ .option('-p, --port <port>', 'Port number to serve on')
89
+ .option('--disableHostCheck', 'Disable host check')
90
+ .option('--open <value>', 'Open browser automatically')
91
+ .option('-d, --debug', 'Enable debug mode')
92
+ .option('--configEnvTarget <target>', 'Environment target for configuration')
93
+ .option('--noLiveReload', 'Disable live reload')
94
+ .option('--project <name>', 'Project name (default: "app")')
95
+ .action((options, command) => handleCommand('./scripts/serve-app', options, command));
96
+
97
+ program
98
+ .command('lint-app')
99
+ .description('Lint the eUI application')
100
+ .option('-p, --project <name>', 'Project name (default: "app")')
101
+ .option('-d, --debug', 'Enable debug mode')
102
+ .action((options, command) => handleCommand('./scripts/lint-app', options, command));
103
+
104
+ program
105
+ .command('inject-config-app')
106
+ .description('Inject configuration into the application')
107
+ .requiredOption('-c, --configEnvTarget <target>', 'Environment target for configuration')
108
+ .option('-d, --debug', 'Enable debug mode')
109
+ .action((options, command) => handleCommand('./scripts/inject-config-app', options, command));
110
+
111
+ program
112
+ .command('generate-sprite')
113
+ .description('Generate SVG sprite')
114
+ .requiredOption('-i, --inFolder <path>', 'Input folder path containing SVG files')
115
+ .requiredOption('-o, --outFile <filename>', 'Output SVG sprite filename (must have .svg extension)')
116
+ .option('-d, --debug', 'Enable debug mode')
117
+ .action((options, command) => handleCommand('./scripts/generate-sprite', options, command));
118
+
119
+ program.parse(process.argv);
@@ -2,11 +2,4 @@
2
2
 
3
3
  const build = require('../../lib/app-utils/build');
4
4
 
5
- Promise.resolve()
6
- .then(() => {
7
- return build.run();
8
- })
9
- .catch((e) => {
10
- console.error(e);
11
- process.exit(1);
12
- });
5
+ module.exports = build.run();
@@ -2,11 +2,4 @@
2
2
 
3
3
  const svgUtils = require('../../lib/app-utils/svg-utils');
4
4
 
5
- Promise.resolve()
6
- .then(() => {
7
- return svgUtils.generateSprite();
8
- })
9
- .catch((e) => {
10
- console.error(e);
11
- process.exit(1);
12
- });
5
+ module.exports = svgUtils.generateSprite();
@@ -2,11 +2,4 @@
2
2
 
3
3
  const common = require('../../lib/app-utils/common');
4
4
 
5
- Promise.resolve()
6
- .then(() => {
7
- return common.injectAppConfig();
8
- })
9
- .catch((e) => {
10
- console.error(e);
11
- process.exit(1);
12
- });
5
+ module.exports = common.injectAppConfig();
@@ -6,17 +6,13 @@ const execSync = childProcess.execSync;
6
6
 
7
7
  const utils = require('../../lib/utils');
8
8
 
9
- Promise.resolve()
10
- .then(() => {
11
- const prjName = 'app';
9
+ module.exports = () => {
10
+ const args = utils.getArgs();
11
+ const prjName = args.project || 'app';
12
12
 
13
13
  utils.logTitle(`Linting application : ${prjName}...`);
14
14
 
15
- const ng = path.resolve(process.cwd(), '@angular', 'cli', 'bin', 'ng');
15
+ const ng = path.resolve(process.cwd(), '@angular', 'cli', 'bin', 'ng');
16
16
 
17
- execSync(`ng lint ${prjName}`);
18
- })
19
- .catch((e) => {
20
- console.error(e);
21
- process.exit(1);
22
- });
17
+ execSync(`ng lint ${prjName}`);
18
+ };
@@ -3,37 +3,38 @@ const generators = require('../../lib/generators');
3
3
  const config = require('../../lib/config');
4
4
  const utils = require('../../lib/utils');
5
5
 
6
- // fetching cli arguments
7
- const args = utils.getArgs();
6
+ module.exports = function run() {
7
+ // fetching cli arguments
8
+ const args = utils.getArgs();
8
9
 
9
- // Print header and version
10
- utils.logBigTitle('eUI CLI');
11
- utils.logAccent(` --- v${config.version} ---\n`);
10
+ // Print header and version
11
+ utils.logBigTitle('eUI CLI');
12
+ utils.logAccent(` --- v${config.version} ---\n`);
12
13
 
13
- // remapping config if passed as argument - automated mode
14
- let inputConfig = config.parseInputConfig(args.config);
14
+ // remapping config if passed as argument - automated mode
15
+ let inputConfig = config.parseInputConfig(args.config);
15
16
 
16
- // Detecting targetPath and create it if present as argument - local and automated mode
17
- let targetPath;
17
+ // Detecting targetPath and create it if present as argument - local and automated mode
18
+ let targetPath;
18
19
 
19
- if (args.targetPath) {
20
- targetPath = path.join(config.targetPath, args.targetPath);
20
+ if (args.targetPath) {
21
+ targetPath = path.join(config.targetPath, args.targetPath);
21
22
 
22
- if (!utils.isDirExists(targetPath)) {
23
- utils.mkdir(targetPath);
24
- }
25
-
26
- // otherwise taking the default config targetPath defined
27
- } else {
28
- targetPath = config.targetPath;
29
- }
23
+ if (!utils.isDirExists(targetPath)) {
24
+ utils.mkdir(targetPath);
25
+ }
30
26
 
31
- if (args.v) {
32
- console.info('Current eUI CLI version installed : ' + config.version);
27
+ // otherwise taking the default config targetPath defined
28
+ } else {
29
+ targetPath = config.targetPath;
30
+ }
33
31
 
34
- } else {
35
- return generators.appGenerate({
36
- inputConfig: inputConfig,
37
- targetPath: targetPath
38
- });
39
- }
32
+ if (args.v) {
33
+ console.info('Current eUI CLI version installed : ' + config.version);
34
+ } else {
35
+ return generators.appGenerate({
36
+ inputConfig: inputConfig,
37
+ targetPath: targetPath
38
+ });
39
+ }
40
+ };
@@ -2,11 +2,4 @@
2
2
 
3
3
  const serve = require('../../lib/app-utils/serve');
4
4
 
5
- Promise.resolve()
6
- .then(() => {
7
- return serve.run();
8
- })
9
- .catch((e) => {
10
- console.error(e);
11
- process.exit(1);
12
- });
5
+ module.exports = serve.run();
@@ -3,8 +3,29 @@ const childProcess = require('child_process');
3
3
  const execSync = childProcess.execSync;
4
4
 
5
5
  const utils = require('../utils');
6
- const common = require('./common');
7
-
6
+ const common = require('./common');
7
+
8
+ /**
9
+ * Runs the application build process with configurable parameters for linting, testing, and compilation.
10
+ *
11
+ * @param {Object} args - Arguments object (retrieved via utils.getArgs())
12
+ * @param {boolean} [args.skipLint] - Skip linting step
13
+ * @param {boolean} [args.skipTest] - Skip testing step
14
+ * @param {boolean} [args.skipCompile] - Skip compilation step
15
+ * @param {string} [args.configuration] - Angular build configuration (defaults to 'production')
16
+ * @param {string} [args.baseHref] - Base href for the application
17
+ * @param {string} [args.servePath] - Serve path for the application
18
+ * @param {boolean} [args.watch] - Enable watch mode for tests
19
+ * @param {boolean} [args.dryRun] - Run in dry-run mode without executing commands
20
+ * @param {boolean} [args.maxSpaceSize] - Use increased memory allocation (8096MB)
21
+ * @param {boolean} [args.statsJson] - Generate stats.json file
22
+ * @param {boolean} [args.ci] - Enable CI mode (disables progress)
23
+ * @param {string} [args.deployUrl] - Deploy URL for the application
24
+ * @param {boolean} [args.sourceMap] - Generate source maps
25
+ * @param {string} [args.configEnvTarget] - Environment target for configuration injection
26
+ * @param {string} [args.project] - Project name (defaults to 'app')
27
+ * @returns {Promise<void>} Promise that resolves when build process is complete
28
+ */
8
29
  module.exports.run = () => {
9
30
  let {
10
31
  skipLint,
@@ -34,21 +55,13 @@ module.exports.run = () => {
34
55
 
35
56
  const ng = path.resolve(process.cwd(), 'node_modules', '@angular', 'cli', 'bin', 'ng');
36
57
 
37
- return Promise.resolve()
38
- .then(() => {
39
58
  if (configEnvTarget) {
40
- return common.injectAppConfig();
59
+ common.injectAppConfig();
41
60
  }
42
- })
43
-
44
- .then(() => {
45
61
  if (!skipLint) {
46
62
  utils.logInfo(`running ng lint ${prjName}`);
47
- execSync(`ng lint ${prjName}`, { cwd: process.cwd(), stdio: 'inherit' });
63
+ execSync(`ng lint ${prjName}`, { cwd: process.cwd(), stdio: 'inherit' });
48
64
  }
49
- })
50
-
51
- .then(() => {
52
65
  if (!skipLint) {
53
66
  utils.logSuccess();
54
67
  }
@@ -77,9 +90,6 @@ module.exports.run = () => {
77
90
  execSync(`node ${args.join(' ')}`, { cwd: process.cwd(), stdio: 'inherit' });
78
91
  }
79
92
  }
80
- })
81
-
82
- .then(() => {
83
93
  if (!skipTest) {
84
94
  utils.logSuccess();
85
95
  }
@@ -99,7 +109,7 @@ module.exports.run = () => {
99
109
 
100
110
  if (configuration) {
101
111
  args.push(`--configuration=${configuration}`);
102
- }
112
+ }
103
113
 
104
114
  if (baseHref) {
105
115
  args.push(`--base-href=${baseHref}`);
@@ -128,10 +138,5 @@ module.exports.run = () => {
128
138
  if (!dryRun && !skipCompile) {
129
139
  execSync(`node ${args.join(' ')}`, { cwd: process.cwd(), stdio: 'inherit' });
130
140
  }
131
- })
132
-
133
- .catch((e) => {
134
- throw e;
135
- });
136
141
  };
137
142
 
@@ -1,9 +1,15 @@
1
1
  const path = require('path');
2
2
  const utils = require('../utils');
3
3
 
4
+ /**
5
+ * Injects application configuration by replacing the default env-json-config.json file
6
+ * with environment-specific configuration.
7
+ *
8
+ * @param {string} args.configEnvTarget - Target environment for configuration injection (required)
9
+ * @returns {Promise<void>} Promise that resolves when configuration injection is complete
10
+ * @throws {Error} When configEnvTarget is not provided or environment config file is missing
11
+ */
4
12
  module.exports.injectAppConfig = () => {
5
- return Promise.resolve()
6
- .then(() => {
7
13
  let { configEnvTarget } = utils.getArgs();
8
14
 
9
15
  if (!configEnvTarget) {
@@ -35,9 +41,4 @@ module.exports.injectAppConfig = () => {
35
41
  utils.copy(envFilePath, path.join(process.cwd(), `${replacedFile}`));
36
42
 
37
43
  utils.logSuccess();
38
- })
39
-
40
- .catch((e) => {
41
- throw e;
42
- });
43
- }
44
+ }
@@ -5,8 +5,29 @@ const childProcess = require('child_process');
5
5
  const execSync = childProcess.execSync;
6
6
 
7
7
  const utils = require('../utils');
8
- const common = require('./common');
9
-
8
+ const common = require('./common');
9
+
10
+ /**
11
+ * Serves an Angular application using ng serve with configurable options.
12
+ *
13
+ * @function run
14
+ * @param {string} [configuration] - Angular build configuration (e.g., 'development', 'production')
15
+ * @param {string} [baseHref] - Base href for the application
16
+ * @param {string} [servePath] - Path to serve the application from
17
+ * @param {string} [host] - Host to serve the application on
18
+ * @param {string} [proxyConfig] - Path to proxy configuration file
19
+ * @param {boolean} [maxSpaceSize] - Enable max old space size of 8192MB for Node.js
20
+ * @param {string|number} [port] - Port number to serve the application on
21
+ * @param {boolean} [disableHostCheck] - Disable host check for webpack dev server
22
+ * @param {string|boolean} [open] - Open browser automatically (default: true, set to 'false' to disable)
23
+ * @param {boolean} [debug] - Enable debug mode
24
+ * @param {boolean} [configEnvTarget] - Inject app configuration before serving
25
+ * @param {boolean} [noLiveReload] - Disable live reload functionality
26
+ * @param {string} [project] - Angular project name to serve (default: 'app')
27
+ * @example
28
+ * // Command line usage:
29
+ * // node script.js --configuration=development --port=4200 --host=localhost
30
+ */
10
31
  module.exports.run = () => {
11
32
 
12
33
  let { configuration, baseHref, servePath, host, proxyConfig, maxSpaceSize, port, disableHostCheck, open, debug, configEnvTarget, noLiveReload, project } = utils.getArgs();
@@ -19,15 +40,9 @@ module.exports.run = () => {
19
40
  prjName = project;
20
41
  }
21
42
 
22
- return Promise.resolve()
23
- .then(() => {
24
43
  if (configEnvTarget) {
25
- return common.injectAppConfig();
44
+ common.injectAppConfig();
26
45
  }
27
- })
28
-
29
- // trigger ng serve with parameters provided
30
- .then(() => {
31
46
  utils.logTitle(`Serving application : ${prjName}...`);
32
47
 
33
48
  let args;
@@ -77,8 +92,4 @@ module.exports.run = () => {
77
92
  utils.logInfo(`ng serve with args ${args}`);
78
93
 
79
94
  return execSync(`node ${args.join(' ')}`, { cwd: process.cwd(), stdio: 'inherit' });
80
- })
81
- .catch((e) => {
82
- throw e;
83
- });
84
95
  }