cubejs-cli 1.1.14 → 1.1.16
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/dist/src/command/auth.js +2 -2
- package/dist/src/command/auth.js.map +1 -1
- package/dist/src/command/deploy.d.ts.map +1 -1
- package/dist/src/command/deploy.js +25 -78
- package/dist/src/command/deploy.js.map +1 -1
- package/dist/src/config.d.ts +3 -35
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +5 -137
- package/dist/src/config.js.map +1 -1
- package/package.json +5 -4
- package/dist/src/deploy.d.ts +0 -12
- package/dist/src/deploy.d.ts.map +0 -1
- package/dist/src/deploy.js +0 -60
- package/dist/src/deploy.js.map +0 -1
package/dist/src/command/auth.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.configureAuthCommand = void 0;
|
|
4
|
+
const cloud_1 = require("@cubejs-backend/cloud");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
|
-
const config_1 = require("../config");
|
|
6
6
|
const authenticate = async (currentToken) => {
|
|
7
|
-
const config = new
|
|
7
|
+
const config = new cloud_1.Config();
|
|
8
8
|
await config.addAuthToken(currentToken);
|
|
9
9
|
await (0, utils_1.event)({
|
|
10
10
|
event: 'Cube Cloud CLI Authenticate'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/command/auth.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/command/auth.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAE/C,oCAA+C;AAE/C,MAAM,YAAY,GAAG,KAAK,EAAE,YAAoB,EAAE,EAAE;IAClD,MAAM,MAAM,GAAG,IAAI,cAAM,EAAE,CAAC;IAC5B,MAAM,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAExC,MAAM,IAAA,aAAK,EAAC;QACV,KAAK,EAAE,6BAA6B;KACrC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,SAAgB,oBAAoB,CAAC,OAAwB;IAC3D,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,mCAAmC,CAAC;SAChD,MAAM,CACL,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC;SACzC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,oBAAY,EAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAC1C;SACA,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACjB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,yMAAyM,CAAC,CAAC;QACvN,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC;AAfD,oDAeC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/command/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/command/deploy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AA4D5C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,QAqB9D"}
|
|
@@ -4,109 +4,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.configureDeployCommand = void 0;
|
|
7
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
8
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
11
|
-
const
|
|
12
|
-
const utils_1 = require("../utils");
|
|
10
|
+
const cloud_1 = require("@cubejs-backend/cloud");
|
|
13
11
|
const config_1 = require("../config");
|
|
14
|
-
const
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const deploy = async ({ directory, auth, uploadEnv, replaceEnv, token }) => {
|
|
15
14
|
if (!(await fs_extra_1.default.pathExists(path_1.default.join(process.cwd(), 'node_modules', '@cubejs-backend/server-core')))) {
|
|
16
15
|
await (0, utils_1.displayError)('@cubejs-backend/server-core dependency not found. Please run deploy command from project root directory and ensure npm install has been run.');
|
|
17
16
|
}
|
|
17
|
+
const config = new config_1.ConfigCli();
|
|
18
18
|
if (token) {
|
|
19
|
-
const config = new config_1.Config();
|
|
20
19
|
await config.addAuthToken(token);
|
|
21
|
-
await (0, utils_1.event)({
|
|
22
|
-
event: 'Cube Cloud CLI Authenticate'
|
|
23
|
-
});
|
|
20
|
+
await (0, utils_1.event)({ event: 'Cube Cloud CLI Authenticate' });
|
|
24
21
|
console.log('Token successfully added!');
|
|
25
22
|
}
|
|
26
|
-
const config = new config_1.Config();
|
|
27
23
|
const bar = new cli_progress_1.default.SingleBar({
|
|
28
24
|
format: '- Uploading files | {bar} | {percentage}% || {value} / {total} | {file}',
|
|
29
25
|
barCompleteChar: '\u2588',
|
|
30
26
|
barIncompleteChar: '\u2591',
|
|
31
27
|
hideCursor: true
|
|
32
28
|
});
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
auth
|
|
44
|
-
});
|
|
45
|
-
if (uploadEnv) {
|
|
46
|
-
const envVariables = await config.envFile(`${directory}/.env`);
|
|
47
|
-
await config.cloudReq({
|
|
48
|
-
url: (deploymentId) => `build/deploy/${deploymentId}/set-env`,
|
|
49
|
-
method: 'POST',
|
|
50
|
-
body: JSON.stringify({
|
|
51
|
-
envVariables: JSON.stringify(envVariables),
|
|
52
|
-
}),
|
|
53
|
-
headers: {
|
|
54
|
-
'Content-type': 'application/json'
|
|
55
|
-
},
|
|
56
|
-
auth
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
await (0, utils_1.logStage)(`Deploying ${deploymentName}...`, 'Cube Cloud CLI Deploy');
|
|
60
|
-
const files = Object.keys(fileHashes);
|
|
61
|
-
const fileHashesPosix = {};
|
|
62
|
-
bar.start(files.length, 0, {
|
|
63
|
-
file: ''
|
|
64
|
-
});
|
|
65
|
-
try {
|
|
66
|
-
for (let i = 0; i < files.length; i++) {
|
|
67
|
-
const file = files[i];
|
|
29
|
+
const envVariables = uploadEnv || replaceEnv ? await config.envFile(`${directory}/.env`) : {};
|
|
30
|
+
const cubeCloudClient = new cloud_1.CubeCloudClient(auth || (await config.deployAuthForCurrentDir()));
|
|
31
|
+
const deployController = new cloud_1.DeployController(cubeCloudClient, { envVariables, replaceEnv }, {
|
|
32
|
+
onStart: async (deploymentName, files) => {
|
|
33
|
+
await (0, utils_1.logStage)(`Deploying ${deploymentName}...`, 'Cube Cloud CLI Deploy');
|
|
34
|
+
bar.start(files.length, 0, {
|
|
35
|
+
file: ''
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
onUpdate: (i, { file }) => {
|
|
68
39
|
bar.update(i, { file });
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
formData.append('file', fs_extra_1.default.createReadStream(path_1.default.join(directory, file)), {
|
|
76
|
-
filename: path_1.default.basename(file),
|
|
77
|
-
contentType: 'application/octet-stream'
|
|
78
|
-
});
|
|
79
|
-
await config.cloudReq({
|
|
80
|
-
url: (deploymentId) => `build/deploy/${deploymentId}/upload-file`,
|
|
81
|
-
method: 'POST',
|
|
82
|
-
body: formData,
|
|
83
|
-
auth,
|
|
84
|
-
headers: formData.getHeaders()
|
|
85
|
-
});
|
|
86
|
-
}
|
|
40
|
+
},
|
|
41
|
+
onUpload: (files) => {
|
|
42
|
+
bar.update(files.length, { file: 'Post processing...' });
|
|
43
|
+
},
|
|
44
|
+
onFinally: () => {
|
|
45
|
+
bar.stop();
|
|
87
46
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
url: (deploymentId) => `build/deploy/${deploymentId}/finish-upload`,
|
|
91
|
-
method: 'POST',
|
|
92
|
-
body: JSON.stringify({
|
|
93
|
-
transaction,
|
|
94
|
-
files: fileHashesPosix
|
|
95
|
-
}),
|
|
96
|
-
headers: { 'Content-type': 'application/json' },
|
|
97
|
-
auth
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
bar.stop();
|
|
102
|
-
}
|
|
47
|
+
});
|
|
48
|
+
await deployController.deploy(directory);
|
|
103
49
|
await (0, utils_1.logStage)('Done 🎉', 'Cube Cloud CLI Deploy Success');
|
|
104
50
|
};
|
|
105
51
|
function configureDeployCommand(program) {
|
|
106
52
|
program
|
|
107
53
|
.command('deploy')
|
|
108
54
|
.description('Deploy project to Cube Cloud')
|
|
109
|
-
.option('--upload-env', '
|
|
55
|
+
.option('--upload-env', 'Use .env file to populate environment variables in Cube Cloud. Only set them once during the very first upload for this deployment')
|
|
56
|
+
.option('--replace-env', 'Use .env file to populate environment variables in Cube Cloud. Replace them with new ones during every upload for this deployment')
|
|
110
57
|
.option('--token <token>', 'Add auth token to CubeCloud')
|
|
111
58
|
.option('--directory [path]', 'Specify path to conf directory', './')
|
|
112
59
|
.action((options) => deploy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/command/deploy.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|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AO;QACV,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,SAAS,CAAC;KACvD,CAAC;SACC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,oBAAY,EAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAC1C;SACA,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACjB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC;AArBD,wDAqBC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -1,46 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type ConfigurationFull = {
|
|
4
|
-
auth: {
|
|
5
|
-
[organizationUrl: string]: {
|
|
6
|
-
auth: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
type Configuration = Partial<ConfigurationFull>;
|
|
11
|
-
export declare class Config {
|
|
12
|
-
protected loadConfig(): Promise<Configuration>;
|
|
13
|
-
protected writeConfig(config: any): Promise<void>;
|
|
14
|
-
protected configFile(): {
|
|
15
|
-
cubeCloudConfigPath: string;
|
|
16
|
-
configFile: string;
|
|
17
|
-
};
|
|
18
|
-
envFile(envFile: string): Promise<dotenv.DotenvParseOutput>;
|
|
19
|
-
protected cubeEnvConfigPath(): string;
|
|
20
|
-
protected cubeCloudConfigPath(): string;
|
|
1
|
+
import { Config } from '@cubejs-backend/cloud';
|
|
2
|
+
export declare class ConfigCli extends Config {
|
|
21
3
|
deployAuth(url?: string): Promise<{
|
|
22
4
|
[organizationUrl: string]: {
|
|
23
5
|
auth: string;
|
|
24
6
|
};
|
|
25
7
|
}>;
|
|
26
|
-
|
|
27
|
-
protected deployAuthForCurrentDir(): Promise<{
|
|
8
|
+
deployAuthForCurrentDir(): Promise<{
|
|
28
9
|
url: any;
|
|
29
10
|
deploymentId: any;
|
|
30
11
|
auth: string;
|
|
31
12
|
}>;
|
|
32
|
-
protected dotCubeCloudFile(): string;
|
|
33
|
-
protected loadDotCubeCloud(): Promise<any>;
|
|
34
|
-
protected writeDotCubeCloud(config: any): Promise<void>;
|
|
35
|
-
cloudReq<T>(options: {
|
|
36
|
-
url: (deploymentId: string) => string;
|
|
37
|
-
auth: {
|
|
38
|
-
auth: string;
|
|
39
|
-
deploymentId?: string;
|
|
40
|
-
url?: string;
|
|
41
|
-
};
|
|
42
|
-
} & RequestInit): Promise<T>;
|
|
43
|
-
protected cloudTokenReq(authToken: string): Promise<any>;
|
|
44
13
|
}
|
|
45
|
-
export {};
|
|
46
14
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,qBAAa,SAAU,SAAQ,MAAM;IACtB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM;;;;;IAmBvB,uBAAuB;;;;;CA6DrC"}
|
package/dist/src/config.js
CHANGED
|
@@ -3,69 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ConfigCli = void 0;
|
|
7
7
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const os_1 = __importDefault(require("os"));
|
|
13
|
-
const dotenv_1 = __importDefault(require("@cubejs-backend/dotenv"));
|
|
14
|
-
const shared_1 = require("@cubejs-backend/shared");
|
|
15
|
-
const utils_1 = require("./utils");
|
|
16
|
-
class Config {
|
|
17
|
-
async loadConfig() {
|
|
18
|
-
const { configFile } = this.configFile();
|
|
19
|
-
if (await fs_extra_1.default.pathExists(configFile)) {
|
|
20
|
-
return fs_extra_1.default.readJson(configFile);
|
|
21
|
-
}
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
async writeConfig(config) {
|
|
25
|
-
const { cubeCloudConfigPath, configFile } = this.configFile();
|
|
26
|
-
await fs_extra_1.default.mkdirp(cubeCloudConfigPath);
|
|
27
|
-
await fs_extra_1.default.writeJson(configFile, config);
|
|
28
|
-
}
|
|
29
|
-
configFile() {
|
|
30
|
-
const cubeCloudConfigPath = this.cubeCloudConfigPath();
|
|
31
|
-
const configFile = path_1.default.join(cubeCloudConfigPath, 'config.json');
|
|
32
|
-
return { cubeCloudConfigPath, configFile };
|
|
33
|
-
}
|
|
34
|
-
async envFile(envFile) {
|
|
35
|
-
if (await fs_extra_1.default.pathExists(envFile)) {
|
|
36
|
-
const env = dotenv_1.default.config({ path: envFile, multiline: 'line-breaks' }).parsed;
|
|
37
|
-
if (env) {
|
|
38
|
-
if ('CUBEJS_DEV_MODE' in env) {
|
|
39
|
-
delete env.CUBEJS_DEV_MODE;
|
|
40
|
-
}
|
|
41
|
-
const resolvePossibleFiles = [
|
|
42
|
-
'CUBEJS_DB_SSL_CA',
|
|
43
|
-
'CUBEJS_DB_SSL_CERT',
|
|
44
|
-
'CUBEJS_DB_SSL_KEY',
|
|
45
|
-
];
|
|
46
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
47
|
-
for (const [key, value] of Object.entries(env)) {
|
|
48
|
-
if (resolvePossibleFiles.includes(key) && (0, shared_1.isFilePath)(value)) {
|
|
49
|
-
if (fs_extra_1.default.existsSync(value)) {
|
|
50
|
-
env[key] = fs_extra_1.default.readFileSync(value, 'ascii');
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
(0, utils_1.displayWarning)(`Unable to resolve file "${value}" from ${key}`);
|
|
54
|
-
env[key] = '';
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return env;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
cubeEnvConfigPath() {
|
|
64
|
-
return path_1.default.join(os_1.default.homedir(), '.env');
|
|
65
|
-
}
|
|
66
|
-
cubeCloudConfigPath() {
|
|
67
|
-
return path_1.default.join(os_1.default.homedir(), '.cubecloud');
|
|
68
|
-
}
|
|
8
|
+
const cloud_1 = require("@cubejs-backend/cloud");
|
|
9
|
+
class ConfigCli extends cloud_1.Config {
|
|
69
10
|
async deployAuth(url) {
|
|
70
11
|
const config = await this.loadConfig();
|
|
71
12
|
if (process.env.CUBE_CLOUD_DEPLOY_AUTH) {
|
|
@@ -80,32 +21,6 @@ class Config {
|
|
|
80
21
|
}]);
|
|
81
22
|
return (await this.addAuthToken(auth.auth, config)).auth;
|
|
82
23
|
}
|
|
83
|
-
async addAuthToken(authToken, config) {
|
|
84
|
-
if (!config) {
|
|
85
|
-
config = await this.loadConfig();
|
|
86
|
-
}
|
|
87
|
-
const payload = jsonwebtoken_1.default.decode(authToken);
|
|
88
|
-
if (payload && typeof payload === 'object' && payload.url) {
|
|
89
|
-
config.auth = config.auth || {};
|
|
90
|
-
config.auth[payload.url] = {
|
|
91
|
-
auth: authToken
|
|
92
|
-
};
|
|
93
|
-
if (payload.deploymentId) {
|
|
94
|
-
const dotCubeCloud = await this.loadDotCubeCloud();
|
|
95
|
-
dotCubeCloud.url = payload.url;
|
|
96
|
-
dotCubeCloud.deploymentId = payload.deploymentId;
|
|
97
|
-
await this.writeDotCubeCloud(dotCubeCloud);
|
|
98
|
-
}
|
|
99
|
-
await this.writeConfig(config);
|
|
100
|
-
return config;
|
|
101
|
-
}
|
|
102
|
-
const answer = await this.cloudTokenReq(authToken);
|
|
103
|
-
if (answer) {
|
|
104
|
-
return this.addAuthToken(answer, config);
|
|
105
|
-
}
|
|
106
|
-
// eslint-disable-next-line no-throw-literal
|
|
107
|
-
throw 'Malformed Cube Cloud token';
|
|
108
|
-
}
|
|
109
24
|
async deployAuthForCurrentDir() {
|
|
110
25
|
const dotCubeCloud = await this.loadDotCubeCloud();
|
|
111
26
|
if (dotCubeCloud.url && dotCubeCloud.deploymentId) {
|
|
@@ -131,11 +46,7 @@ class Config {
|
|
|
131
46
|
}])).url;
|
|
132
47
|
}
|
|
133
48
|
const authToken = auth[url];
|
|
134
|
-
const deployments = await this.
|
|
135
|
-
url: () => 'build/deploy/deployments',
|
|
136
|
-
method: 'GET',
|
|
137
|
-
auth: { ...authToken, url }
|
|
138
|
-
});
|
|
49
|
+
const deployments = await this.cubeCloudClient.getDeploymentsList({ auth: { ...authToken, url } });
|
|
139
50
|
if (!Array.isArray(deployments)) {
|
|
140
51
|
throw new Error(JSON.stringify(deployments));
|
|
141
52
|
}
|
|
@@ -163,49 +74,6 @@ class Config {
|
|
|
163
74
|
deploymentId
|
|
164
75
|
};
|
|
165
76
|
}
|
|
166
|
-
dotCubeCloudFile() {
|
|
167
|
-
return '.cubecloud';
|
|
168
|
-
}
|
|
169
|
-
async loadDotCubeCloud() {
|
|
170
|
-
if (await fs_extra_1.default.pathExists(this.dotCubeCloudFile())) {
|
|
171
|
-
return fs_extra_1.default.readJson(this.dotCubeCloudFile());
|
|
172
|
-
}
|
|
173
|
-
return {};
|
|
174
|
-
}
|
|
175
|
-
async writeDotCubeCloud(config) {
|
|
176
|
-
await fs_extra_1.default.writeJson(this.dotCubeCloudFile(), config);
|
|
177
|
-
}
|
|
178
|
-
async cloudReq(options) {
|
|
179
|
-
const { url, auth, ...restOptions } = options;
|
|
180
|
-
const authorization = auth || await this.deployAuthForCurrentDir();
|
|
181
|
-
if (!authorization) {
|
|
182
|
-
throw new Error('Auth isn\'t set');
|
|
183
|
-
}
|
|
184
|
-
// Ensure headers object exists in restOptions
|
|
185
|
-
restOptions.headers = restOptions.headers || {};
|
|
186
|
-
// Add authorization to headers
|
|
187
|
-
restOptions.headers.authorization = authorization.auth;
|
|
188
|
-
const response = await (0, node_fetch_1.default)(`${authorization.url}/${url(authorization.deploymentId || '')}`, restOptions);
|
|
189
|
-
if (!response.ok) {
|
|
190
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
191
|
-
}
|
|
192
|
-
return await response.json();
|
|
193
|
-
}
|
|
194
|
-
async cloudTokenReq(authToken) {
|
|
195
|
-
const res = await (0, node_fetch_1.default)(`${process.env.CUBE_CLOUD_HOST || 'https://cubecloud.dev'}/v1/token`, {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
headers: { 'Content-type': 'application/json' },
|
|
198
|
-
body: JSON.stringify({ token: authToken })
|
|
199
|
-
});
|
|
200
|
-
if (!res.ok) {
|
|
201
|
-
throw new Error(`HTTP error! status: ${res.status}`);
|
|
202
|
-
}
|
|
203
|
-
const response = await res.json();
|
|
204
|
-
if (!response.jwt) {
|
|
205
|
-
throw new Error('JWT token is not present in the response');
|
|
206
|
-
}
|
|
207
|
-
return response.jwt;
|
|
208
|
-
}
|
|
209
77
|
}
|
|
210
|
-
exports.
|
|
78
|
+
exports.ConfigCli = ConfigCli;
|
|
211
79
|
//# sourceMappingURL=config.js.map
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,iDAA+C;AAE/C,M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ACrB,CAAC,CAAC,CAAC;YACJ,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC;SAChE;QAED,MAAM,IAAI,CAAC,iBAAiB,CAAC;YAC3B,GAAG;YACH,YAAY;SACb,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,SAAS;YACZ,GAAG;YACH,YAAY;SACb,CAAC;IACJ,CAAC;CACF;AAjFD,8BAiFC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "cubejs-cli",
|
|
3
3
|
"description": "Cube.js Command Line Interface",
|
|
4
4
|
"author": "Cube Dev, Inc.",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.16",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/cube-js/cube.git",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@cubejs-backend/cloud": "1.1.16",
|
|
33
34
|
"@cubejs-backend/dotenv": "^9.0.2",
|
|
34
|
-
"@cubejs-backend/schema-compiler": "1.1.
|
|
35
|
+
"@cubejs-backend/schema-compiler": "1.1.16",
|
|
35
36
|
"@cubejs-backend/shared": "1.1.12",
|
|
36
37
|
"chalk": "^2.4.2",
|
|
37
38
|
"cli-progress": "^3.10",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@cubejs-backend/linter": "^1.0.0",
|
|
53
|
-
"@cubejs-backend/server": "1.1.
|
|
54
|
+
"@cubejs-backend/server": "1.1.16",
|
|
54
55
|
"@oclif/command": "^1.8.0",
|
|
55
56
|
"@types/cli-progress": "^3.8.0",
|
|
56
57
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"eslintConfig": {
|
|
72
73
|
"extends": "../cubejs-linter"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "924a17cf930acd7ecbe4d50105e724bf17d3881a"
|
|
75
76
|
}
|
package/dist/src/deploy.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type DeployDirectoryOptions = {
|
|
2
|
-
directory: string;
|
|
3
|
-
};
|
|
4
|
-
export declare class DeployDirectory {
|
|
5
|
-
protected readonly options: DeployDirectoryOptions;
|
|
6
|
-
constructor(options: DeployDirectoryOptions);
|
|
7
|
-
fileHashes(directory?: string): Promise<{}>;
|
|
8
|
-
protected filter(file: string): boolean;
|
|
9
|
-
protected fileHash(file: string): Promise<unknown>;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=deploy.d.ts.map
|
package/dist/src/deploy.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/deploy.ts"],"names":[],"mappings":"AAIA,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qBAAa,eAAe;IAExB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB;gBAA/B,OAAO,EAAE,sBAAsB;IAGvC,UAAU,CAAC,SAAS,GAAE,MAA+B;IAuBlE,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM;IAgB7B,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;CAUhC"}
|
package/dist/src/deploy.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DeployDirectory = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
class DeployDirectory {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this.options = options;
|
|
14
|
-
}
|
|
15
|
-
async fileHashes(directory = this.options.directory) {
|
|
16
|
-
let result = {};
|
|
17
|
-
const files = await fs_extra_1.default.readdir(directory);
|
|
18
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
19
|
-
for (const file of files) {
|
|
20
|
-
const filePath = path_1.default.resolve(directory, file);
|
|
21
|
-
if (!this.filter(filePath)) {
|
|
22
|
-
// eslint-disable-next-line no-continue
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
const stat = await fs_extra_1.default.stat(filePath);
|
|
26
|
-
if (stat.isDirectory()) {
|
|
27
|
-
result = { ...result, ...await this.fileHashes(filePath) };
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
result[path_1.default.relative(this.options.directory, filePath)] = {
|
|
31
|
-
hash: await this.fileHash(filePath)
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
filter(file) {
|
|
38
|
-
const baseName = path_1.default.basename(file);
|
|
39
|
-
// whitelist
|
|
40
|
-
if (['.gitignore'].includes(baseName)) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
// blacklist
|
|
44
|
-
if (['dashboard-app', 'node_modules'].includes(baseName)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return baseName.charAt(0) !== '.';
|
|
48
|
-
}
|
|
49
|
-
fileHash(file) {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
const hash = crypto_1.default.createHash('sha1');
|
|
52
|
-
const stream = fs_extra_1.default.createReadStream(file);
|
|
53
|
-
stream.on('error', err => reject(err));
|
|
54
|
-
stream.on('data', chunk => hash.update(chunk));
|
|
55
|
-
stream.on('end', () => resolve(hash.digest('hex')));
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.DeployDirectory = DeployDirectory;
|
|
60
|
-
//# sourceMappingURL=deploy.js.map
|
package/dist/src/deploy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/deploy.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,wDAA0B;AAC1B,gDAAwB;AAMxB,MAAa,eAAe;IAEL;IADrB,YACqB,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;IAChD,CAAC;IAEE,KAAK,CAAC,UAAU,CAAC,YAAoB,IAAI,CAAC,OAAO,CAAC,SAAS;QAChE,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC1C,gDAAgD;QAChD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBAC1B,uCAAuC;gBACvC,SAAS;aACV;YACD,MAAM,IAAI,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtB,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;aAC5D;iBAAM;gBACL,MAAM,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,GAAG;oBACxD,IAAI,EAAE,MAAM,IAA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