mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-39314 Break dependencies on the "commander" lib in the CLI (#11299)
This commit is contained in:
+29
-2
@@ -18,12 +18,24 @@ adf-cli <command> --help
|
|||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
Link the project as a global tool
|
### Quick Setup
|
||||||
|
|
||||||
|
Link the project as a global tool (builds and links in one command):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm link
|
npm run link
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This will build the CLI and make the `adf-cli` command available globally on your system.
|
||||||
|
|
||||||
|
When you're done developing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run unlink
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development Mode
|
||||||
|
|
||||||
Build the tool in the **develop** mode (automatically watches for changes and rebuilds the commands):
|
Build the tool in the **develop** mode (automatically watches for changes and rebuilds the commands):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -38,6 +50,21 @@ DEVELOP=true adf-cli <command>
|
|||||||
|
|
||||||
In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|
In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|
||||||
|
|
||||||
|
### Manual Workflow
|
||||||
|
|
||||||
|
If you need more control, you can manually build and link:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the CLI
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# Or build with full distribution (includes copying resources)
|
||||||
|
npm run dist
|
||||||
|
|
||||||
|
# Link from the dist directory
|
||||||
|
cd ../../dist/libs/cli && npm link
|
||||||
|
```
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
| **Commands** | **Description** |
|
| **Commands** | **Description** |
|
||||||
|
|||||||
+15
-3
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const minimist = require('minimist');
|
const { parseArgs } = require('node:util');
|
||||||
const { resolve, join } = require('node:path');
|
const { resolve, join } = require('node:path');
|
||||||
const { readFileSync, existsSync } = require('node:fs');
|
const { readFileSync, existsSync } = require('node:fs');
|
||||||
const { argv, exit, env, cwd } = require('node:process');
|
const { argv, exit, env, cwd } = require('node:process');
|
||||||
@@ -10,10 +10,22 @@ function printHelp() {
|
|||||||
console.log(`${name} v${version}`);
|
console.log(`${name} v${version}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = minimist(argv.slice(2), {
|
const { values, positionals } = parseArgs({
|
||||||
boolean: ['verbose']
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
verbose: {
|
||||||
|
type: 'boolean'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true,
|
||||||
|
strict: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
...values,
|
||||||
|
_: positionals
|
||||||
|
};
|
||||||
|
|
||||||
if (args._.length === 0) {
|
if (args._.length === 0) {
|
||||||
printHelp();
|
printHelp();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
@@ -17,15 +17,15 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.json",
|
"build": "tsc -p tsconfig.json",
|
||||||
"develop": "tsc -p tsconfig.json --watch",
|
"develop": "tsc -p tsconfig.json --watch",
|
||||||
"dist": "rm -rf ../../dist/libs/cli && npm run build && cp -R ./bin ../../dist/libs/cli && cp -R ./resources ../../dist/libs/cli && cp -R ./templates ../../dist/libs/cli && cp ./package.json ../../dist/libs/cli"
|
"dist": "rm -rf ../../dist/libs/cli && npm run build && cp -R ./bin ../../dist/libs/cli && cp -R ./resources ../../dist/libs/cli && cp -R ./templates ../../dist/libs/cli && cp ./package.json ../../dist/libs/cli",
|
||||||
|
"link": "npm run dist && cd ../../dist/libs/cli && npm link",
|
||||||
|
"unlink": "cd ../../dist/libs/cli && npm unlink"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@alfresco/js-api": ">=8.4.0-0",
|
"@alfresco/js-api": ">=8.4.0-0",
|
||||||
"commander": "^6.2.1",
|
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
"license-checker": "^25.0.1",
|
"license-checker": "^25.0.1",
|
||||||
"node-fetch": "^2.7.0",
|
"node-fetch": "^2.7.0",
|
||||||
"rxjs": "7.8.2",
|
|
||||||
"shelljs": "^0.10.0",
|
"shelljs": "^0.10.0",
|
||||||
"spdx-license-list": "^5.0.0"
|
"spdx-license-list": "^5.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+30
-12
@@ -22,9 +22,7 @@ import * as ejs from 'ejs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
import { Command } from 'commander';
|
import { parseArgs } from 'node:util';
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
|
|
||||||
interface AuditCommandArgs {
|
interface AuditCommandArgs {
|
||||||
package?: string;
|
package?: string;
|
||||||
@@ -39,19 +37,39 @@ interface AuditCommandArgs {
|
|||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
export default function main(_args: string[], workingDir: string) {
|
export default function main(_args: string[], workingDir: string) {
|
||||||
program
|
|
||||||
.description('Generate an audit report')
|
|
||||||
.usage('audit [options]')
|
|
||||||
.option('-p, --package <path>', 'Path to package file (default: package.json in working directory)')
|
|
||||||
.option('-d, --outDir <dir>', 'Ouput directory (default: working directory)')
|
|
||||||
.parse(argv);
|
|
||||||
|
|
||||||
if (argv.includes('-h') || argv.includes('--help')) {
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
program.outputHelp();
|
console.log(`
|
||||||
|
Usage: audit [options]
|
||||||
|
|
||||||
|
Generate an audit report
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --package <path> Path to package file (default: package.json in working directory)
|
||||||
|
-d, --outDir <dir> Output directory (default: working directory)
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: AuditCommandArgs = program.opts();
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
package: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
outDir: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'd'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const options: AuditCommandArgs = {
|
||||||
|
package: values.package as string | undefined,
|
||||||
|
outDir: values.outDir as string | undefined
|
||||||
|
};
|
||||||
|
|
||||||
let packagePath = path.resolve(workingDir, 'package.json');
|
let packagePath = path.resolve(workingDir, 'package.json');
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,13 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
import * as shell from 'shelljs';
|
import * as shell from 'shelljs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { Command } from 'commander';
|
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as ejs from 'ejs';
|
import * as ejs from 'ejs';
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
|
|
||||||
interface Commit {
|
interface Commit {
|
||||||
hash: string;
|
hash: string;
|
||||||
author: string;
|
author: string;
|
||||||
@@ -151,28 +149,74 @@ function commitAuthorAllowed(commit: Commit, authorFilter: string): boolean {
|
|||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
export default function main(_args: string[], workingDir: string) {
|
export default function main(_args: string[], workingDir: string) {
|
||||||
program
|
|
||||||
.description('Generate changelog report for two branches of git repository')
|
|
||||||
.version('0.0.1', '-v, --version')
|
|
||||||
.usage('changelog [options]')
|
|
||||||
.option('-r, --range <range>', 'Commit range, e.g. origin/master..develop', 'origin/master..develop')
|
|
||||||
.option('-d, --dir <dir>', 'Working directory (default: working directory)')
|
|
||||||
.option('-m, --max <number>', 'Limit the number of commits to output')
|
|
||||||
.option('-o, --output <dir>', 'Output directory, will use console output if not defined')
|
|
||||||
.option('--skip <number>', 'Skip number commits before starting to show the commit output')
|
|
||||||
.option('-f, --format <format>', 'Output format (md, html)', 'md')
|
|
||||||
.option('-e --exclude <string>', 'Exclude authors from the output, comma-delimited list')
|
|
||||||
.parse(argv);
|
|
||||||
|
|
||||||
if (argv.includes('-h') || argv.includes('--help')) {
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
program.outputHelp();
|
console.log(`
|
||||||
|
Usage: changelog [options]
|
||||||
|
|
||||||
|
Generate changelog report for two branches of git repository
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-v, --version Output the version number
|
||||||
|
-r, --range <range> Commit range, e.g. origin/master..develop (default: "origin/master..develop")
|
||||||
|
-d, --dir <dir> Working directory (default: working directory)
|
||||||
|
-m, --max <number> Limit the number of commits to output
|
||||||
|
-o, --output <dir> Output directory, will use console output if not defined
|
||||||
|
--skip <number> Skip number commits before starting to show the commit output
|
||||||
|
-f, --format <format> Output format (md, html) (default: "md")
|
||||||
|
-e, --exclude <string> Exclude authors from the output, comma-delimited list
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = program.opts();
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.0.1');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
const dir = path.resolve(options.dir || workingDir);
|
const { values } = parseArgs({
|
||||||
const { range, skip, max, format, output, exclude } = options;
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
range: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'r',
|
||||||
|
default: 'origin/master..develop'
|
||||||
|
},
|
||||||
|
dir: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'd'
|
||||||
|
},
|
||||||
|
max: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'm'
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'o'
|
||||||
|
},
|
||||||
|
skip: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'f',
|
||||||
|
default: 'md'
|
||||||
|
},
|
||||||
|
exclude: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'e'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const dir = path.resolve((values.dir as string) || workingDir);
|
||||||
|
const range = values.range as string;
|
||||||
|
const skip = values.skip ? parseInt(values.skip as string, 10) : undefined;
|
||||||
|
const max = values.max ? parseInt(values.max as string, 10) : undefined;
|
||||||
|
const format = values.format as string;
|
||||||
|
const output = values.output as string | undefined;
|
||||||
|
const exclude = values.exclude as string | undefined;
|
||||||
|
|
||||||
const remote = getRemote(dir);
|
const remote = getRemote(dir);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { AlfrescoApi /*, NodesApi, UploadApi*/ } from '@alfresco/js-api';
|
import { AlfrescoApi /*, NodesApi, UploadApi*/ } from '@alfresco/js-api';
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
import { Command } from 'commander';
|
import { parseArgs } from 'node:util';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
|
|
||||||
interface CheckCsEnvArgs {
|
interface CheckCsEnvArgs {
|
||||||
@@ -27,8 +27,6 @@ interface CheckCsEnvArgs {
|
|||||||
time?: number;
|
time?: number;
|
||||||
retry?: number;
|
retry?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
const MAX_RETRY = 3;
|
const MAX_RETRY = 3;
|
||||||
const TIMEOUT = 20000;
|
const TIMEOUT = 20000;
|
||||||
|
|
||||||
@@ -39,18 +37,63 @@ let alfrescoJsApi: AlfrescoApi;
|
|||||||
* Check CS environment command
|
* Check CS environment command
|
||||||
*/
|
*/
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
program
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
.version('0.1.0')
|
console.log(`
|
||||||
.description('Check Content service is up ')
|
Usage: check-cs-env [options]
|
||||||
.usage('check-cs-env [options]')
|
|
||||||
.option('--host [type]', 'Remote environment host adf.lab.com ')
|
Check Content service is up
|
||||||
.option('-p, --password [type]', 'password ')
|
|
||||||
.option('-u, --username [type]', 'username ')
|
Options:
|
||||||
.option('-t, --time [type]', 'time ')
|
-v, --version Output the version number
|
||||||
.option('-r, --retry [type]', 'retry ')
|
--host <host> Remote environment host adf.lab.com
|
||||||
.parse(argv);
|
-p, --password <pass> Password
|
||||||
|
-u, --username <user> Username
|
||||||
|
-t, --time <ms> Time in milliseconds
|
||||||
|
-r, --retry <num> Retry count
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.1.0');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
host: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'u'
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: 'string',
|
||||||
|
short: 't'
|
||||||
|
},
|
||||||
|
retry: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'r'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const opts: CheckCsEnvArgs = {
|
||||||
|
host: values.host as string | undefined,
|
||||||
|
username: values.username as string | undefined,
|
||||||
|
password: values.password as string | undefined,
|
||||||
|
time: values.time ? parseInt(values.time as string, 10) : undefined,
|
||||||
|
retry: values.retry ? parseInt(values.retry as string, 10) : undefined
|
||||||
|
};
|
||||||
|
|
||||||
const opts = program.opts();
|
|
||||||
await checkEnv(opts);
|
await checkEnv(opts);
|
||||||
// TODO: https://alfresco.atlassian.net/browse/ACS-5873
|
// TODO: https://alfresco.atlassian.net/browse/ACS-5873
|
||||||
// await checkDiskSpaceFullEnv();
|
// await checkDiskSpaceFullEnv();
|
||||||
|
|||||||
@@ -15,14 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { argv } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
import { CheckEnv } from './plugins/check-env';
|
import { CheckEnv } from './plugins/check-env';
|
||||||
import { Command } from 'commander';
|
|
||||||
import { ProcessServiceCheckPlugin } from './plugins/process-service-check-plugin';
|
import { ProcessServiceCheckPlugin } from './plugins/process-service-check-plugin';
|
||||||
import { ProcessAutomationCheckPlugin } from './plugins/process-automation-check-plugin';
|
import { ProcessAutomationCheckPlugin } from './plugins/process-automation-check-plugin';
|
||||||
import { GovernanceCheckPlugin } from './plugins/governance-check-plugin';
|
import { GovernanceCheckPlugin } from './plugins/governance-check-plugin';
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
let pluginEnv: CheckEnv;
|
let pluginEnv: CheckEnv;
|
||||||
|
|
||||||
interface CheckPluginArgs {
|
interface CheckPluginArgs {
|
||||||
@@ -39,18 +38,74 @@ interface CheckPluginArgs {
|
|||||||
* Check environment plugin
|
* Check environment plugin
|
||||||
*/
|
*/
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
program
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
.version('0.1.0')
|
console.log(`
|
||||||
.option('--host [type]', 'Remote environment host')
|
Usage: check-plugin-env [options]
|
||||||
.option('--pluginName [type]', 'pluginName')
|
|
||||||
.option('--clientId [type]', 'sso client', 'alfresco')
|
|
||||||
.option('--appName [type]', 'appName ', 'Deployed appName on activiti-cloud')
|
|
||||||
.option('-p, --password [type]', 'password ')
|
|
||||||
.option('-u, --username [type]', 'username ')
|
|
||||||
.option('--ui, --uiName [type]', 'uiName', 'Deployed app UI type on activiti-cloud')
|
|
||||||
.parse(argv);
|
|
||||||
|
|
||||||
const options = program.opts();
|
Check plugin status
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-v, --version Output the version number
|
||||||
|
--host <host> Remote environment host
|
||||||
|
--pluginName <name> Plugin name (processService, processAutomation, governance)
|
||||||
|
--clientId <id> SSO client (default: "alfresco")
|
||||||
|
--appName <name> Deployed appName on activiti-cloud
|
||||||
|
-p, --password <pass> Password
|
||||||
|
-u, --username <user> Username
|
||||||
|
--ui, --uiName <name> Deployed app UI type on activiti-cloud
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.1.0');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
host: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
pluginName: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
clientId: {
|
||||||
|
type: 'string',
|
||||||
|
default: 'alfresco'
|
||||||
|
},
|
||||||
|
appName: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'u'
|
||||||
|
},
|
||||||
|
ui: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
uiName: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const options: CheckPluginArgs = {
|
||||||
|
host: values.host as string | undefined,
|
||||||
|
pluginName: values.pluginName as 'processService' | 'processAutomation' | 'governance' | undefined,
|
||||||
|
clientId: values.clientId as string | undefined,
|
||||||
|
appName: values.appName as string | undefined,
|
||||||
|
username: values.username as string | undefined,
|
||||||
|
password: values.password as string | undefined,
|
||||||
|
uiName: (values.ui || values.uiName) as string | undefined
|
||||||
|
};
|
||||||
|
|
||||||
pluginEnv = new CheckEnv(options.host, options.username, options.password, options.clientId);
|
pluginEnv = new CheckEnv(options.host, options.username, options.password, options.clientId);
|
||||||
await pluginEnv.checkEnv();
|
await pluginEnv.checkEnv();
|
||||||
|
|||||||
@@ -17,14 +17,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Command } from 'commander';
|
import { parseArgs } from 'node:util';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
const ACTIVITI_CLOUD_APPS = require('./resources').ACTIVITI_CLOUD_APPS;
|
const ACTIVITI_CLOUD_APPS = require('./resources').ACTIVITI_CLOUD_APPS;
|
||||||
|
|
||||||
let alfrescoJsApiModeler: AlfrescoApi;
|
let alfrescoJsApiModeler: AlfrescoApi;
|
||||||
@@ -730,32 +728,103 @@ async function sleep(time: number) {
|
|||||||
* Init AAE environment command
|
* Init AAE environment command
|
||||||
*/
|
*/
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
program
|
if (argv.includes('--help')) {
|
||||||
.version('0.1.0')
|
console.log(`
|
||||||
.description(
|
Usage: init-aae-env [options]
|
||||||
'The following command is in charge of Initializing the activiti cloud env with the default apps' +
|
|
||||||
'adf-cli init-aae-env --host "gateway_env" --modelerUsername "modelerusername" --modelerPassword "modelerpassword" --devopsUsername "devevopsusername" --devopsPassword "devopspassword"'
|
|
||||||
)
|
|
||||||
.option('-h, --host [type]', 'Host gateway')
|
|
||||||
.option('--oauth [type]', 'SSO host')
|
|
||||||
.option('--clientId [type]', 'sso client')
|
|
||||||
.option('--secret [type]', 'sso secret', '')
|
|
||||||
.option('--scope [type]', 'sso scope', 'openid')
|
|
||||||
.option('--tokenEndpoint [type]', 'discovery token Endpoint', 'auth/realms/${clientId}/protocol/openid-connect/token')
|
|
||||||
.option('--modelerUsername [type]', 'username of a user with role ACTIVIT_MODELER')
|
|
||||||
.option('--modelerPassword [type]', 'modeler password')
|
|
||||||
.option('--devopsUsername [type]', 'username of a user with role ACTIVIT_DEVOPS')
|
|
||||||
.option('--devopsPassword [type]', 'devops password')
|
|
||||||
.option('--tag [type]', 'tag name of the codebase')
|
|
||||||
.option('--envs [type...]', 'environment ids of the envs where to deploy the app')
|
|
||||||
.parse(argv);
|
|
||||||
|
|
||||||
if (argv.includes('-h') || argv.includes('--help')) {
|
Initialize the activiti cloud env with the default apps
|
||||||
program.outputHelp();
|
|
||||||
|
Example:
|
||||||
|
adf-cli init-aae-env --host "gateway_env" --modelerUsername "modelerusername" \\
|
||||||
|
--modelerPassword "modelerpassword" --devopsUsername "devopsusername" \\
|
||||||
|
--devopsPassword "devopspassword"
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-v, --version Output the version number
|
||||||
|
-h, --host <host> Host gateway
|
||||||
|
--oauth <host> SSO host
|
||||||
|
--clientId <id> SSO client
|
||||||
|
--secret <secret> SSO secret (default: "")
|
||||||
|
--scope <scope> SSO scope (default: "openid")
|
||||||
|
--tokenEndpoint <endpoint> Discovery token endpoint (default: "auth/realms/\${clientId}/protocol/openid-connect/token")
|
||||||
|
--modelerUsername <username> Username of a user with role ACTIVIT_MODELER
|
||||||
|
--modelerPassword <password> Modeler password
|
||||||
|
--devopsUsername <username> Username of a user with role ACTIVIT_DEVOPS
|
||||||
|
--devopsPassword <password> Devops password
|
||||||
|
--tag <tag> Tag name of the codebase
|
||||||
|
--envs <envs...> Environment ids of the envs where to deploy the app
|
||||||
|
--help Display help for command
|
||||||
|
`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = initializeDefaultToken(program.opts() as ConfigArgs);
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.1.0');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
host: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'h'
|
||||||
|
},
|
||||||
|
oauth: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
clientId: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
secret: {
|
||||||
|
type: 'string',
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
scope: {
|
||||||
|
type: 'string',
|
||||||
|
default: 'openid'
|
||||||
|
},
|
||||||
|
tokenEndpoint: {
|
||||||
|
type: 'string',
|
||||||
|
default: 'auth/realms/${clientId}/protocol/openid-connect/token'
|
||||||
|
},
|
||||||
|
modelerUsername: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
modelerPassword: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
devopsUsername: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
devopsPassword: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
tag: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
envs: {
|
||||||
|
type: 'string',
|
||||||
|
multiple: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = initializeDefaultToken({
|
||||||
|
host: values.host as string,
|
||||||
|
oauth: values.oauth as string,
|
||||||
|
clientId: values.clientId as string,
|
||||||
|
secret: values.secret as string,
|
||||||
|
scope: values.scope as string,
|
||||||
|
tokenEndpoint: values.tokenEndpoint as string,
|
||||||
|
modelerUsername: values.modelerUsername as string,
|
||||||
|
modelerPassword: values.modelerPassword as string,
|
||||||
|
devopsUsername: values.devopsUsername as string,
|
||||||
|
devopsPassword: values.devopsPassword as string,
|
||||||
|
tag: values.tag as string,
|
||||||
|
envs: (values.envs as string[]) || []
|
||||||
|
} as ConfigArgs);
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
host: options.host,
|
host: options.host,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { AlfrescoApi, SharedlinksApi, FavoritesApi, NodesApi, UploadApi, NodeEntry } from '@alfresco/js-api';
|
import { AlfrescoApi, SharedlinksApi, FavoritesApi, NodesApi, UploadApi, NodeEntry } from '@alfresco/js-api';
|
||||||
import { exit, argv } from 'node:process';
|
import { exit, argv } from 'node:process';
|
||||||
import { Command } from 'commander';
|
import { parseArgs } from 'node:util';
|
||||||
import { createReadStream } from 'fs';
|
import { createReadStream } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
@@ -28,8 +28,6 @@ interface InitAcsEnvArgs {
|
|||||||
username?: string;
|
username?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
const MAX_RETRY = 10;
|
const MAX_RETRY = 10;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
const TIMEOUT = 6000;
|
const TIMEOUT = 6000;
|
||||||
@@ -41,15 +39,57 @@ let alfrescoJsApi: AlfrescoApi;
|
|||||||
* Init ACS environment command
|
* Init ACS environment command
|
||||||
*/
|
*/
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
program
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
.version('0.1.0')
|
console.log(`
|
||||||
.option('--host [type]', 'Remote environment host')
|
Usage: init-acs-env [options]
|
||||||
.option('--clientId [type]', 'sso client', 'alfresco')
|
|
||||||
.option('-p, --password [type]', 'password ')
|
Initialize ACS environment
|
||||||
.option('-u, --username [type]', 'username ')
|
|
||||||
.parse(argv);
|
Options:
|
||||||
|
-v, --version Output the version number
|
||||||
|
--host <host> Remote environment host
|
||||||
|
--clientId <id> SSO client (default: "alfresco")
|
||||||
|
-p, --password <pass> Password
|
||||||
|
-u, --username <user> Username
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.1.0');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
host: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
clientId: {
|
||||||
|
type: 'string',
|
||||||
|
default: 'alfresco'
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'u'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const opts: InitAcsEnvArgs = {
|
||||||
|
host: values.host as string | undefined,
|
||||||
|
clientId: values.clientId as string | undefined,
|
||||||
|
username: values.username as string | undefined,
|
||||||
|
password: values.password as string | undefined
|
||||||
|
};
|
||||||
|
|
||||||
const opts = program.opts();
|
|
||||||
await checkEnv(opts);
|
await checkEnv(opts);
|
||||||
|
|
||||||
logger.info(`***** Step initialize ACS *****`);
|
logger.info(`***** Step initialize ACS *****`);
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ import {
|
|||||||
AppDefinitionUpdateResultRepresentation
|
AppDefinitionUpdateResultRepresentation
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
import { spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import { createReadStream } from 'node:fs';
|
import { createReadStream } from 'node:fs';
|
||||||
import { Command } from 'commander';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { throwError } from 'rxjs';
|
|
||||||
|
|
||||||
interface InitApsEnvArgs {
|
interface InitApsEnvArgs {
|
||||||
host?: string;
|
host?: string;
|
||||||
@@ -40,8 +39,6 @@ interface InitApsEnvArgs {
|
|||||||
password?: string;
|
password?: string;
|
||||||
license?: string;
|
license?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
const MAX_RETRY = 10;
|
const MAX_RETRY = 10;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
const TIMEOUT = 6000;
|
const TIMEOUT = 6000;
|
||||||
@@ -56,16 +53,62 @@ let alfrescoJsApi: AlfrescoApi;
|
|||||||
* Init APS command
|
* Init APS command
|
||||||
*/
|
*/
|
||||||
export default async function main() {
|
export default async function main() {
|
||||||
program
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
.version('0.1.0')
|
console.log(`
|
||||||
.option('--host [type]', 'Remote environment host')
|
Usage: init-aps-env [options]
|
||||||
.option('--clientId [type]', 'sso client', 'alfresco')
|
|
||||||
.option('-p, --password [type]', 'password ')
|
Initialize APS environment
|
||||||
.option('-u, --username [type]', 'username ')
|
|
||||||
.option('--license [type]', 'APS license S3 path ')
|
Options:
|
||||||
.parse(argv);
|
-v, --version Output the version number
|
||||||
|
--host <host> Remote environment host
|
||||||
|
--clientId <id> SSO client (default: "alfresco")
|
||||||
|
-p, --password <pass> Password
|
||||||
|
-u, --username <user> Username
|
||||||
|
--license <path> APS license S3 path
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.includes('-v') || argv.includes('--version')) {
|
||||||
|
console.log('0.1.0');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
host: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
clientId: {
|
||||||
|
type: 'string',
|
||||||
|
default: 'alfresco'
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'u'
|
||||||
|
},
|
||||||
|
license: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const opts: InitApsEnvArgs = {
|
||||||
|
host: values.host as string | undefined,
|
||||||
|
clientId: values.clientId as string | undefined,
|
||||||
|
username: values.username as string | undefined,
|
||||||
|
password: values.password as string | undefined,
|
||||||
|
license: values.license as string | undefined
|
||||||
|
};
|
||||||
|
|
||||||
const opts = program.opts();
|
|
||||||
await checkEnv(opts);
|
await checkEnv(opts);
|
||||||
|
|
||||||
logger.info(`***** Step 1 - Check License *****`);
|
logger.info(`***** Step 1 - Check License *****`);
|
||||||
@@ -207,9 +250,9 @@ async function hasDefaultTenant(tenantId: number, tenantName: string): Promise<b
|
|||||||
logger.info(`Aps: has default tenantId: ${tenantId} and name ${tenantName}`);
|
logger.info(`Aps: has default tenantId: ${tenantId} and name ${tenantName}`);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
logger.info(`Wrong configuration. Another tenant has been created with id ${tenant.id} and name ${tenant.name}`);
|
const errorMessage = `Wrong configuration. Another tenant has been created with id ${tenant.id} and name ${tenant.name}`;
|
||||||
throwError(`Wrong configuration. Another tenant has been created with id ${tenant.id} and name ${tenant.name}`);
|
logger.error(errorMessage);
|
||||||
return false;
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+31
-12
@@ -18,14 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { argv, exit } from 'node:process';
|
import { argv, exit } from 'node:process';
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as checker from 'license-checker';
|
import * as checker from 'license-checker';
|
||||||
import * as licenseList from 'spdx-license-list';
|
import * as licenseList from 'spdx-license-list';
|
||||||
import * as ejs from 'ejs';
|
import * as ejs from 'ejs';
|
||||||
import { Command } from 'commander';
|
|
||||||
|
|
||||||
const program = new Command();
|
|
||||||
|
|
||||||
interface LicensesCommandArgs {
|
interface LicensesCommandArgs {
|
||||||
package?: string;
|
package?: string;
|
||||||
@@ -103,19 +101,40 @@ function getPackageFile(packagePath: string): PackageInfo {
|
|||||||
* @returns void function
|
* @returns void function
|
||||||
*/
|
*/
|
||||||
export default function main(_args: string[], workingDir: string) {
|
export default function main(_args: string[], workingDir: string) {
|
||||||
program
|
|
||||||
.description('Generate a licences report')
|
|
||||||
.usage('licenses [options]')
|
|
||||||
.option('-p, --package <path>', 'Path to package file (default: package.json in working directory)')
|
|
||||||
.option('-d, --outDir <dir>', 'Ouput directory (default: working directory)')
|
|
||||||
.parse(argv);
|
|
||||||
|
|
||||||
if (argv.includes('-h') || argv.includes('--help')) {
|
if (argv.includes('-h') || argv.includes('--help')) {
|
||||||
program.outputHelp();
|
console.log(`
|
||||||
|
Usage: licenses [options]
|
||||||
|
|
||||||
|
Generate a licenses report
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --package <path> Path to package file (default: package.json in working directory)
|
||||||
|
-d, --outDir <dir> Output directory (default: working directory)
|
||||||
|
-h, --help Display help for command
|
||||||
|
`);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const options: LicensesCommandArgs = program.opts();
|
const { values } = parseArgs({
|
||||||
|
args: argv.slice(2),
|
||||||
|
options: {
|
||||||
|
package: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'p'
|
||||||
|
},
|
||||||
|
outDir: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'd'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowPositionals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const options: LicensesCommandArgs = {
|
||||||
|
package: values.package as string | undefined,
|
||||||
|
outDir: values.outDir as string | undefined
|
||||||
|
};
|
||||||
|
|
||||||
let packagePath = path.resolve(workingDir, 'package.json');
|
let packagePath = path.resolve(workingDir, 'package.json');
|
||||||
|
|
||||||
if (options.package) {
|
if (options.package) {
|
||||||
|
|||||||
Reference in New Issue
Block a user