@contrail/cli 3.1.4 → 3.1.7
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
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.1.
|
|
20
|
+
@contrail/cli/3.1.7 darwin-arm64 node-v20.18.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -147,9 +147,10 @@ Deploy an extension from the extensions directory to a VibeIQ managed URL.
|
|
|
147
147
|
|
|
148
148
|
```
|
|
149
149
|
USAGE
|
|
150
|
-
$ contrail app extension deploy -i <value> [-l error|warn|info|debug] [-e true|false]
|
|
150
|
+
$ contrail app extension deploy -i <value> [-l error|warn|info|debug] [-e true|false] [-d]
|
|
151
151
|
|
|
152
152
|
FLAGS
|
|
153
|
+
-d, --debug Enable debug mode
|
|
153
154
|
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
154
155
|
<options: true|false>
|
|
155
156
|
-i, --identifier=<value> (required) The extension identifier to deploy. The identifier of the extension is the
|
|
@@ -4,6 +4,7 @@ export default class DeployExtension extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
identifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -24,6 +24,11 @@ class DeployExtension extends basecommand_1.BaseCommand {
|
|
|
24
24
|
description: 'The extension identifier to deploy. The identifier of the extension is the "identifier" property in the extension defined in the app.yml',
|
|
25
25
|
required: true,
|
|
26
26
|
}),
|
|
27
|
+
debug: core_1.Flags.boolean({
|
|
28
|
+
char: 'd',
|
|
29
|
+
description: 'Enable debug mode',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
27
32
|
};
|
|
28
33
|
async run() {
|
|
29
34
|
await (0, login_1.authUser)();
|
|
@@ -35,7 +40,7 @@ class DeployExtension extends basecommand_1.BaseCommand {
|
|
|
35
40
|
await this.validateExtensionDeclaration(appDeclaration, extensionIdentifier);
|
|
36
41
|
const extensionDir = this.getExtensionDirectory(extensionIdentifier);
|
|
37
42
|
// 2. Package and upload extension
|
|
38
|
-
const createdPackage = await (0, extension_package_1.createExtensionPackage)(app.id, extensionDir);
|
|
43
|
+
const createdPackage = await (0, extension_package_1.createExtensionPackage)(app.id, extensionDir, { debug: this.flags.debug });
|
|
39
44
|
// 3. Poll until package is ready (timeout after 1 minute)
|
|
40
45
|
const readyPackage = await this.pollUntilPackageIsReady(createdPackage);
|
|
41
46
|
logger_1.default.info("Extension package is ready...Checking for extension deployment");
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { App } from '@contrail/entity-types';
|
|
2
2
|
import { AppDeclaration, AppExtensionPackage } from '../../interfaces';
|
|
3
|
-
export declare function createExtensionPackage(appId: string, extensionDir: string
|
|
3
|
+
export declare function createExtensionPackage(appId: string, extensionDir: string, options: {
|
|
4
|
+
debug: boolean;
|
|
5
|
+
}): Promise<any>;
|
|
4
6
|
export declare function getExistingApp(appDeclaration: AppDeclaration): Promise<App>;
|
|
5
7
|
export declare function getExtensionPackage(packageId: string): Promise<AppExtensionPackage>;
|
|
@@ -32,27 +32,12 @@ function cleanAndPrepareTmpDir(extensionDir, tmpDir) {
|
|
|
32
32
|
function cleanUp(tmpDir) {
|
|
33
33
|
fs_1.default.rmSync(tmpDir, { recursive: true, force: true });
|
|
34
34
|
}
|
|
35
|
-
function installDependencies(tmpDir) {
|
|
36
|
-
try {
|
|
37
|
-
logger_1.default.info('Installing production dependencies started...');
|
|
38
|
-
const child_process = require('child_process');
|
|
39
|
-
child_process.execSync('npm install --omit=dev --prefix ./', {
|
|
40
|
-
cwd: tmpDir,
|
|
41
|
-
stdio: 'inherit',
|
|
42
|
-
});
|
|
43
|
-
logger_1.default.info('Installing production dependencies done.');
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Failed during dependency install: ${e}`);
|
|
47
|
-
throw e;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
35
|
function buildExtension(packageId, extensionDir, tmpDir) {
|
|
51
36
|
try {
|
|
52
37
|
logger_1.default.info('Building package...');
|
|
53
38
|
const child_process = require('child_process');
|
|
54
39
|
console.log('Building package... in ', tmpDir);
|
|
55
|
-
child_process.execSync(`npx ng build --output-path ${tmpDir}/dist --deploy-url /packages/${packageId}/`, {
|
|
40
|
+
child_process.execSync(`npx ng build --output-path "${tmpDir}/dist" --deploy-url /packages/${packageId}/`, {
|
|
56
41
|
cwd: extensionDir,
|
|
57
42
|
stdio: 'inherit',
|
|
58
43
|
});
|
|
@@ -71,7 +56,7 @@ function copyAssets(extensionDir, tmpDir) {
|
|
|
71
56
|
try {
|
|
72
57
|
logger_1.default.info('Copying Assets...');
|
|
73
58
|
const child_process = require('child_process');
|
|
74
|
-
child_process.execSync(`npx copyfiles assets/**/* ${tmpDir}/dist
|
|
59
|
+
child_process.execSync(`npx copyfiles assets/**/* "${tmpDir}/dist/"`, {
|
|
75
60
|
cwd: extensionDir,
|
|
76
61
|
stdio: 'inherit',
|
|
77
62
|
});
|
|
@@ -96,12 +81,12 @@ async function zipDist(tmpDir) {
|
|
|
96
81
|
throw err;
|
|
97
82
|
}
|
|
98
83
|
}
|
|
99
|
-
async function uploadExtensionPackage(appExtensionPackage, tmpDir) {
|
|
84
|
+
async function uploadExtensionPackage(appExtensionPackage, tmpDir, options) {
|
|
100
85
|
const tmpZipPath = path_1.default.join(tmpDir, 'dist.zip');
|
|
101
86
|
const readStream = fs_1.default.readFileSync(tmpZipPath);
|
|
102
87
|
const postBody = Buffer.from(readStream);
|
|
103
88
|
console.log('extension package ', JSON.stringify(appExtensionPackage, null, 2));
|
|
104
|
-
await axios_1.default.request({
|
|
89
|
+
const result = await axios_1.default.request({
|
|
105
90
|
method: 'PUT',
|
|
106
91
|
url: appExtensionPackage.uploadURL,
|
|
107
92
|
data: postBody,
|
|
@@ -111,9 +96,17 @@ async function uploadExtensionPackage(appExtensionPackage, tmpDir) {
|
|
|
111
96
|
});
|
|
112
97
|
logger_1.default.debug(`${chalk_1.default.green.bold('EXTENSION')} Uploaded extension package to ${appExtensionPackage.uploadURL}`);
|
|
113
98
|
logger_1.default.info(`${chalk_1.default.green.bold('EXTENSION')} Extension package uploaded. ID: ${appExtensionPackage.id}`);
|
|
99
|
+
if (options.debug) {
|
|
100
|
+
logger_1.default.debug(JSON.stringify(result, null, 2));
|
|
101
|
+
}
|
|
102
|
+
if (result.status !== 200) {
|
|
103
|
+
logger_1.default.error(`${chalk_1.default.red.bold('EXTENSION')} Failed to upload extension package. Status: ${result.status}`);
|
|
104
|
+
logger_1.default.error(JSON.stringify(result, null, 2));
|
|
105
|
+
throw new Error(`Failed to upload extension package. Status: ${result.status}`);
|
|
106
|
+
}
|
|
114
107
|
return appExtensionPackage;
|
|
115
108
|
}
|
|
116
|
-
async function createExtensionPackage(appId, extensionDir) {
|
|
109
|
+
async function createExtensionPackage(appId, extensionDir, options) {
|
|
117
110
|
const tmpDir = createTmpDir(extensionDir);
|
|
118
111
|
logger_1.default.info(`${chalk_1.default.blue.bold('START')} Creating extension package at ${tmpDir}`);
|
|
119
112
|
cleanAndPrepareTmpDir(extensionDir, tmpDir);
|
|
@@ -126,9 +119,14 @@ async function createExtensionPackage(appId, extensionDir) {
|
|
|
126
119
|
buildExtension(appExtensionPackage.id, extensionDir, tmpDir);
|
|
127
120
|
copyAssets(extensionDir, tmpDir);
|
|
128
121
|
await zipDist(tmpDir);
|
|
129
|
-
await uploadExtensionPackage(appExtensionPackage, tmpDir);
|
|
122
|
+
await uploadExtensionPackage(appExtensionPackage, tmpDir, options);
|
|
130
123
|
logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Extension packaged and uploaded.`);
|
|
131
|
-
|
|
124
|
+
if (options.debug) {
|
|
125
|
+
logger_1.default.debug("debug mode enabled. Not cleaning up tmp dir.");
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
cleanUp(tmpDir);
|
|
129
|
+
}
|
|
132
130
|
return appExtensionPackage;
|
|
133
131
|
}
|
|
134
132
|
exports.createExtensionPackage = createExtensionPackage;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.1.
|
|
2
|
+
"version": "3.1.7",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -3056,6 +3056,13 @@
|
|
|
3056
3056
|
"description": "The extension identifier to deploy. The identifier of the extension is the \"identifier\" property in the extension defined in the app.yml",
|
|
3057
3057
|
"required": true,
|
|
3058
3058
|
"multiple": false
|
|
3059
|
+
},
|
|
3060
|
+
"debug": {
|
|
3061
|
+
"name": "debug",
|
|
3062
|
+
"type": "boolean",
|
|
3063
|
+
"char": "d",
|
|
3064
|
+
"description": "Enable debug mode",
|
|
3065
|
+
"allowNo": false
|
|
3059
3066
|
}
|
|
3060
3067
|
},
|
|
3061
3068
|
"args": {}
|