Skip to content

Commit

Permalink
Merge branch 'staging' into fix/migration
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Nov 18, 2024
2 parents 3913b29 + 7fe493e commit 165305a
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 37 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
2 changes: 1 addition & 1 deletion packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"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
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
2 changes: 1 addition & 1 deletion 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 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
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"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
2 changes: 1 addition & 1 deletion 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
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/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
6 changes: 3 additions & 3 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.30.0",
"version": "1.31.0",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -34,8 +34,8 @@
"@contentstack/cli-cm-migrate-rte": "~1.4.20",
"@contentstack/cli-cm-seed": "~1.10.0",
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-config": "~1.8.0",
"@contentstack/cli-launch": "~1.2.3",
"@contentstack/cli-config": "~1.9.0",
"@contentstack/cli-launch": "~1.3.0",
"@contentstack/cli-migration": "~1.6.4",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.3",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 165305a

Please sign in to comment.