Skip to content

Commit

Permalink
Merge pull request #1683 from contentstack/staging
Browse files Browse the repository at this point in the history
Release 20-11-2024 | Launch | CLI integration on GCP
  • Loading branch information
aman19K authored Nov 20, 2024
2 parents 7c78837 + 4c74be1 commit 1f4bf6f
Show file tree
Hide file tree
Showing 27 changed files with 273 additions and 350 deletions.
258 changes: 105 additions & 153 deletions package-lock.json

Large diffs are not rendered by default.

Empty file modified package.json
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
"@oclif/test": "^4.1.0",
"@oclif/test": "^4.1.2",
"@types/chai": "^4.3.20",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/1.3.22 darwin-arm64 node-v22.2.0
@contentstack/cli-auth/1.3.22 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/1.13.0 darwin-arm64 node-v22.2.0
@contentstack/cli-cm-bootstrap/1.13.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"promise-limit": "^2.7.0",
"proxyquire": "^2.1.3",
"tslib": "^2.8.1",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-auth": "~1.3.22",
"@contentstack/cli-config": "~1.8.0",
"@contentstack/cli-config": "~1.9.0",
"@contentstack/cli-dev-dependencies": "~1.2.4",
"@oclif/plugin-help": "^5.2.20",
"@oclif/test": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bulk-publish/1.7.0 darwin-arm64 node-v22.2.0
@contentstack/cli-cm-bulk-publish/1.7.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"inquirer": "8.2.6",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4",
"nock": "^13.5.5",
"winston": "^3.16.0"
"nock": "^13.5.6",
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ora": "^5.4.1",
"prompt": "^1.3.0",
"rimraf": "^5.0.10",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-config/1.8.0 darwin-arm64 node-v22.2.0
@contentstack/cli-config/1.9.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-config",
"description": "Contentstack CLI plugin for configuration",
"version": "1.8.0",
"version": "1.9.0",
"author": "Contentstack",
"scripts": {
"build": "npm run clean && npm run compile",
Expand All @@ -28,7 +28,7 @@
"inquirer": "8.2.6",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/src/utils/region-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const regions = {
uiHost: 'https://gcp-na-app.contentstack.com',
name: 'GCP-NA',
'developerHubUrl': 'https://gcp-na-developerhub-api.contentstack.com',
'launchHubUrl': 'Not available',
'launchHubUrl': 'https://gcp-na-launch-api.contentstack.com',
'personalizeUrl': 'https://gcp-na-personalize-api.contentstack.com',
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"promise-limit": "^2.7.0",
"proxyquire": "^2.1.3",
"tslib": "^2.8.1",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-auth": "~1.3.22",
"@contentstack/cli-config": "~1.8.0",
"@contentstack/cli-config": "~1.9.0",
"@contentstack/cli-dev-dependencies": "~1.2.4",
"@oclif/plugin-help": "^5.2.20",
"@oclif/test": "^4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-launch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-launch
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-launch/1.2.3 darwin-arm64 node-v22.2.0
@contentstack/cli-launch/1.3.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-launch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-launch",
"version": "1.2.3",
"version": "1.3.0",
"description": "Launch related operations",
"author": "Contentstack CLI",
"bin": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"ini": "^3.0.1",
"lodash": "^4.17.21",
"open": "^8.4.2",
"winston": "^3.15.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.0",
Expand All @@ -53,7 +53,7 @@
"oclif": "^3.17.2",
"shx": "^0.3.4",
"ts-node": "^10.9.2",
"tslib": "^2.7.0",
"tslib": "^2.8.1",
"typescript": "^4.9.5"
},
"oclif": {
Expand Down
22 changes: 11 additions & 11 deletions packages/contentstack-launch/src/adapters/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import includes from 'lodash/includes';
import isEmpty from 'lodash/isEmpty';
import { basename, resolve } from 'path';
import { cliux, configHandler, HttpClient, ux } from '@contentstack/cli-utilities';
import { createReadStream, existsSync, PathLike, statSync } from 'fs';
import { createReadStream, existsSync, PathLike, statSync, readFileSync } from 'fs';

import { print } from '../util';
import BaseClass from './base-class';
Expand Down Expand Up @@ -63,7 +63,6 @@ export default class FileUpload extends BaseClass {
*/
async createNewProject(): Promise<void> {
const { framework, projectName, buildCommand, outputDirectory, environmentName } = this.config;

await this.apolloClient
.mutate({
mutation: importProjectMutation,
Expand Down Expand Up @@ -215,7 +214,7 @@ export default class FileUpload extends BaseClass {

switch (true) {
case state.isDirectory(): // NOTE folder
await zip.addLocalFolderPromise(entryPath, { zipPath: entry });
zip.addLocalFolder(entryPath, entry);
break;
case state.isFile(): // NOTE check is file
zip.addLocalFile(entryPath);
Expand Down Expand Up @@ -264,7 +263,7 @@ export default class FileUpload extends BaseClass {
* @memberof FileUpload
*/
async uploadFile(fileName: string, filePath: PathLike): Promise<void> {
const { uploadUrl, fields, headers } = this.signedUploadUrlData;
const { uploadUrl, fields, headers, method } = this.signedUploadUrlData;
const formData = new FormData();

if (!isEmpty(fields)) {
Expand All @@ -274,8 +273,8 @@ export default class FileUpload extends BaseClass {

formData.append('file', createReadStream(filePath), fileName);
await this.submitFormData(formData, uploadUrl);
} else if (!isEmpty(headers)) {
await this.uploadWithHttpClient(filePath, uploadUrl, headers, fileName);
} else if (method === 'PUT') {
await this.uploadWithHttpClient(filePath, uploadUrl, headers);
}
}

Expand Down Expand Up @@ -307,28 +306,29 @@ export default class FileUpload extends BaseClass {
filePath: PathLike,
uploadUrl: string,
headers: Array<{ key: string; value: string }>,
fileName: string,
): Promise<void> {
ux.action.start('Starting file upload...');
const httpClient = new HttpClient();
const form = new FormData();
form.append('file', createReadStream(filePath), fileName);
const file = readFileSync(filePath);

// Convert headers array to a headers object
const headerObject = headers.reduce((acc, { key, value }) => {
const headerObject = headers?.reduce((acc, { key, value }) => {
acc[key] = value;
return acc;
}, {} as Record<string, string>);

try {
const response = await httpClient.headers(headerObject).put(uploadUrl, form);
httpClient.headers({ 'Content-Type': 'application/zip' });
if (headerObject !== undefined) httpClient.headers(headerObject);
const response = (await httpClient.put(uploadUrl, file)) as any;
const { status } = response;

if (status >= 200 && status < 300) {
ux.action.stop();
} else {
ux.action.stop('File upload failed!');
this.log('File upload failed. Please try again.', 'error');
this.log(`Error: ${status}, ${response?.statusText}`, 'error');
this.exit(1);
}
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-launch/src/graphql/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const createSignedUploadUrlMutation: DocumentNode = gql`
key
value
}
method
}
}
`;
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-migrate-rte/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-migrate-rte
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-migrate-rte/1.4.20 darwin-arm64 node-v22.2.0
@contentstack/cli-cm-migrate-rte/1.4.20 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-migrate-rte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^3.17.2",
"tslib": "^1.14.1"
"tslib": "^2.8.1"
},
"engines": {
"node": ">=14.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-migration/1.6.3 darwin-arm64 node-v22.2.0
@contentstack/cli-migration/1.6.4 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-migration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-migration",
"version": "1.6.3",
"version": "1.6.4",
"author": "@contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand All @@ -14,7 +14,7 @@
"dot-object": "^2.1.5",
"dotenv": "^16.4.5",
"listr": "^0.14.3",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.0",
Expand Down
19 changes: 7 additions & 12 deletions packages/contentstack-migration/src/utils/modules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const { execFileSync } = require('child_process');
const { spawnSync } = require('child_process');
const path = require('path');
const { sanitizePath } = require('@contentstack/cli-utilities');
const os = require('os');
Expand Down Expand Up @@ -61,27 +61,22 @@ function installDependencies(dependencies, directory) {
if (!internalModules.has(dep)) {
const pkg = dep.startsWith('@') ? dep : dep.split('/')[0];
if (!installedDependencies.has(pkg)) {
executeShellCommand(`npm i ${pkg}`, directory);
executeShellCommand(pkg, directory);
installedDependencies.add(pkg);
}
}
});
}

function executeShellCommand(command, directory = '') {
function executeShellCommand(pkg, directory = '') {
try {
if (command.startsWith('npm i')) {
const [cmd, ...args] = command.split(' ');
execFileSync(cmd, args, { stdio: 'inherit', cwd: directory });
console.log(`Command executed successfully: ${command}`);
} else {
console.log(`Command should only be 'npm i <package-name>'`);
}
const result = spawnSync(`npm`, ['i', pkg], { stdio: 'inherit', cwd: directory, shell: false });
if (result?.error) throw result.error;
console.log(`Command executed successfully: ${command}`);
} catch (error) {
console.error(`Command execution failed. Error: ${error.message}`);
console.error(`Command execution failed. Error: ${error?.message}`);
}
}

async function installModules(filePath, multiple) {
const files = multiple ? [] : [path.basename(filePath)];
const dirPath = multiple ? filePath : path.dirname(filePath);
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@contentstack/marketplace-sdk": "^1.2.1",
"@oclif/core": "^3.27.0",
"axios": "^1.7.4",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"cli-cursor": "^3.1.0",
"cli-table": "^0.3.11",
"conf": "^10.2.0",
Expand All @@ -56,7 +56,7 @@
"traverse": "^0.6.10",
"unique-string": "^2.0.0",
"uuid": "^9.0.1",
"winston": "^3.14.2",
"winston": "^3.17.0",
"xdg-basedir": "^4.0.0"
},
"devDependencies": {
Expand All @@ -82,7 +82,7 @@
"sinon": "^19.0.2",
"tmp": "^0.2.3",
"ts-node": "^10.9.2",
"tslib": "^1.14.1",
"tslib": "^2.8.1",
"typescript": "^4.9.5"
}
}
2 changes: 1 addition & 1 deletion packages/contentstack-variants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"chai": "^4.5.0",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"sinon": "^17.0.2",
"sinon": "^19.0.2",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "^5.6.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli/1.30.0 darwin-arm64 node-v22.8.0
@contentstack/cli/1.31.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
Loading

0 comments on commit 1f4bf6f

Please sign in to comment.