Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 55 Development to Staging #1370

Merged
merged 34 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5da1cef
fix: Resolved the issue of private apps re-creation after selecting n…
cs-raj Mar 28, 2024
2c4fe7a
removed console log and changed the condition for private app creation
cs-raj Mar 28, 2024
36d5a5c
Merge branch 'staging' into stage-to-development
cs-raj Apr 1, 2024
27c5513
Merge pull request #1361 from contentstack/stage-to-development
cs-raj Apr 1, 2024
bcbbe0d
Ui text updated
cs-raj Apr 2, 2024
46bda1e
Merge branch 'development' into bugfix/CS-44299
cs-raj Apr 2, 2024
faec438
Modified the change master locale script to adapt to new file structu…
cs-raj Apr 2, 2024
3c94467
PR code review changes and variable name changed
cs-raj Apr 3, 2024
3e121bf
Merge pull request #1363 from contentstack/fix/CS-44196
cs-raj Apr 3, 2024
c4aa6e6
Merge branch 'staging' into staging-to-development
cs-raj Apr 3, 2024
8ac23cb
staging-to-development
cs-raj Apr 3, 2024
382a9ac
Merge pull request #1366 from contentstack/staging-to-development
cs-raj Apr 3, 2024
79a46f2
Reverted the URL sanitization by reverting the changes to the previou…
cs-raj Apr 4, 2024
f97a0b4
version bump
cs-raj Apr 5, 2024
74bb466
Merge branch 'development' into bugfix/CS-44299
cs-raj Apr 5, 2024
c42d245
Merge pull request #1358 from contentstack/bugfix/CS-44299
cs-raj Apr 5, 2024
bf3a48b
updated logs while publishing
cs-raj Apr 8, 2024
69e10f4
handled the case when no branches are passed to check and version bump
cs-raj Apr 10, 2024
c745c17
PR comments resolution
cs-raj Apr 10, 2024
edccfaf
UI text updates
cs-raj Apr 10, 2024
11d48d9
Merge branch 'development' into bugfix/CS-44574
cs-raj Apr 10, 2024
f27727b
fixed the bulk publishing of all entries when single entry is passed …
cs-raj Apr 10, 2024
ae9eabb
Merge branch 'development' into bugfix/CS-44642
cs-raj Apr 10, 2024
e719f63
modified the code
cs-raj Apr 10, 2024
75013b3
Merge branch 'development' into bugfix/CS-44112
cs-raj Apr 10, 2024
087d48b
issue in prepack
cs-raj Apr 12, 2024
5363b18
Merge pull request #1369 from contentstack/bugfix/CS-44112
cs-raj Apr 12, 2024
36a79a5
Merge remote-tracking branch 'origin/development' into bugfix/CS-44574
cs-raj Apr 12, 2024
95765f0
lock-file update
cs-raj Apr 12, 2024
c034262
Merge pull request #1367 from contentstack/bugfix/CS-44574
cs-raj Apr 12, 2024
ee8cd34
Merge remote-tracking branch 'origin/development' into bugfix/CS-44642
cs-raj Apr 12, 2024
0efa3d5
lock file update
cs-raj Apr 12, 2024
88de6ff
Merge branch 'development' into bugfix/CS-44642
cs-raj Apr 12, 2024
0a34d78
Merge pull request #1368 from contentstack/bugfix/CS-44642
cs-raj Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,151 changes: 14,587 additions & 2,564 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.5.2",
"version": "1.5.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
35 changes: 20 additions & 15 deletions packages/contentstack-audit/src/modules/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,20 @@ export default class Workflows {

for (const workflow of this.workflowSchema) {
const ctNotPresent = workflow.content_types.filter((ct) => !this.ctUidSet.has(ct));
const branch = workflow?.branches?.filter((branch) => branch !== this.config?.branch);
let branchesToBeRemoved: string[] = [];
if (this.config?.branch) {
branchesToBeRemoved = workflow?.branches?.filter((branch) => branch !== this.config?.branch) || [];
}

if (ctNotPresent.length || branch?.length) {
if (ctNotPresent.length || branchesToBeRemoved?.length) {
const tempwf = cloneDeep(workflow);
tempwf.content_types = ctNotPresent || [];

if (workflow?.branches) {
tempwf.branches = branch;
if (workflow?.branches && this.config?.branch) {
tempwf.branches = branchesToBeRemoved;
}

if (branch?.length) {
if (branchesToBeRemoved?.length) {
this.isBranchFixDone = true;
}

Expand Down Expand Up @@ -111,17 +114,19 @@ export default class Workflows {
const fixedCts = workflow.content_types.filter((ct) => !this.missingCts.has(ct));
const fixedBranches: string[] = [];

workflow?.branches?.forEach((branch) => {
if (branch !== this.config?.branch) {
const { uid, name } = workflow;
this.log($t(commonMsg.WF_BRANCH_REMOVAL, { uid, name, branch }), { color: 'yellow' });
} else {
fixedBranches.push(branch);
if (this.config.branch) {
workflow?.branches?.forEach((branch) => {
if (branch !== this.config?.branch) {
const { uid, name } = workflow;
this.log($t(commonMsg.WF_BRANCH_REMOVAL, { uid, name, branch }), { color: 'yellow' });
} else {
fixedBranches.push(branch);
}
});

if (fixedBranches.length > 0) {
newWorkflowSchema[workflow.uid].branches = fixedBranches;
}
});

if (fixedBranches.length > 0) {
newWorkflowSchema[workflow.uid].branches = fixedBranches;
}

if (fixedCts.length) {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bulk-publish/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bulk-publish",
"description": "Contentstack CLI plugin for bulk publish actions",
"version": "1.4.3",
"version": "1.4.4",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ async function getSyncEntries(

const entriesResponse = await Stack.sync(syncData);

if (filter?.content_type_uid?.length) {
entriesResponse.items = entriesResponse.items.filter((entry) =>
filter?.content_type_uid.includes(entry.content_type_uid),
);
}

if (entriesResponse.items.length > 0) {
await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion);
}
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 @@ -7,7 +7,7 @@
"dependencies": {
"@colors/colors": "^1.5.0",
"@contentstack/cli-cm-export": "~1.11.1",
"@contentstack/cli-cm-import": "~1.15.0",
"@contentstack/cli-cm-import": "~1.15.1",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.6.0",
"async": "^3.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function createNodeCryptoInstance(config: ExportConfig): Promise<No

return true;
},
message: 'Enter marketplace app configurations encryption key',
message: 'Enter Marketplace app configurations encryption key',
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.15.0",
"version": "1.15.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.5.2",
"@contentstack/cli-audit": "~1.5.3",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.6.0",
"@contentstack/management": "~1.15.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module.exports = class ImportMarketplaceApps {

return true;
},
message: 'Enter marketplace app configurations encryption key',
message: 'Enter Marketplace app configurations encryption key',
});

try {
Expand Down
14 changes: 8 additions & 6 deletions packages/contentstack-import/src/import/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export default class EntriesImport extends BaseClass {

async replaceEntriesHandler({
apiParams,
element: entry
element: entry,
}: {
apiParams: ApiOptions;
element: Record<string, string>;
Expand Down Expand Up @@ -876,19 +876,21 @@ export default class EntriesImport extends BaseClass {
}
// log(this.importConfig, `Starting publish entries for ${cTUid} in locale ${locale}`, 'info');

const onSuccess = ({ response, apiData: { environments, entryUid }, additionalInfo }: any) => {
const onSuccess = ({ response, apiData: { environments, entryUid, locales }, additionalInfo }: any) => {
log(
this.importConfig,
`Published entry: '${entryUid}' of content type ${cTUid} and locale ${locale} in ${environments?.join(
`Published the entry: '${entryUid}' of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments?.join(
',',
)} environments`,
)}' and Locales '${locales?.join(',')}'`,
'info',
);
};
const onReject = ({ error, apiData, additionalInfo }: any) => {
const onReject = ({ error, apiData: { environments, entryUid, locales }, additionalInfo }: any) => {
log(
this.importConfig,
`${apiData.entryUid} entry of content type ${cTUid} in locale ${locale} failed to publish`,
`Failed to publish: '${entryUid}' entry of Content Type '${cTUid}' and Locale '${locale}' in Environments '${environments?.join(
',',
)}' and Locales '${locales?.join(',')}'`,
'error',
);
log(this.importConfig, formatError(error), 'error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,35 +231,38 @@ export default class ImportMarketplaceApps {
return Promise.resolve();
}

await getConfirmationToCreateApps(privateApps, this.importConfig);

log(this.importConfig, 'Starting developer hub private apps re-creation', 'success');
let canCreatePrivateApp = await getConfirmationToCreateApps(privateApps, this.importConfig);
this.importConfig.canCreatePrivateApp = canCreatePrivateApp;
if (canCreatePrivateApp) {
log(this.importConfig, 'Starting developer hub private apps re-creation', 'success');
for (let app of privateApps) {
if (this.importConfig.skipPrivateAppRecreationIfExist && (await this.isPrivateAppExistInDeveloperHub(app))) {
// NOTE Found app already exist in the same org
this.appUidMapping[app.uid] = app.uid;
cliux.print(`App '${app.manifest.name}' already exist. skipping app recreation.!`, { color: 'yellow' });
continue;
}

for (let app of privateApps) {
if (this.importConfig.skipPrivateAppRecreationIfExist && (await this.isPrivateAppExistInDeveloperHub(app))) {
// NOTE Found app already exist in the same org
this.appUidMapping[app.uid] = app.uid;
cliux.print(`App '${app.manifest.name}' already exist. skipping app recreation.!`, { color: 'yellow' });
continue;
// NOTE keys can be passed to install new app in the developer hub
const validKeys = [
'uid',
'name',
'icon',
'oauth',
'webhook',
'visibility',
'target_type',
'description',
'ui_location',
'framework_version',
];
const manifest = pick(app.manifest, validKeys) as Manifest;
this.appOriginalName = manifest.name;

await this.createPrivateApp(manifest);
}

// NOTE keys can be passed to install new app in the developer hub
const validKeys = [
'uid',
'name',
'icon',
'oauth',
'webhook',
'visibility',
'target_type',
'description',
'ui_location',
'framework_version',
];
const manifest = pick(app.manifest, validKeys) as Manifest;
this.appOriginalName = manifest.name;

await this.createPrivateApp(manifest);
} else {
log(this.importConfig, 'Skipping private apps creation on Developer Hub...', 'success');
}

this.appOriginalName = undefined;
Expand Down Expand Up @@ -422,6 +425,10 @@ export default class ImportMarketplaceApps {

if (!currentStackApp) {
// NOTE install new app
if (app.manifest.visibility === 'private' && !this.importConfig.canCreatePrivateApp) {
log(this.importConfig, `Skipping the installation of the private app ${app.manifest.name}...`, 'info');
return Promise.resolve();
}
const installation = await this.installApp(
this.importConfig,
// NOTE if it's private app it should get uid from mapper else will use manifest uid
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-import/src/types/import-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ExternalConfig {
}

export default interface ImportConfig extends DefaultConfig, ExternalConfig {
canCreatePrivateApp: boolean;
contentDir: string;
data: string;
management_token?: string;
Expand Down
8 changes: 5 additions & 3 deletions packages/contentstack-import/src/utils/asset-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ export const lookupAssets = function (
assetUrls.forEach(function (assetUrl: any) {
let mappedAssetUrl = mappedAssetUrls[assetUrl];
if (typeof mappedAssetUrl !== 'undefined') {
const sanitizedUrl = escapeRegExp(assetUrl).replace(/\.\./g, '\\$&');
const escapedMappedUrl = escapeRegExp(mappedAssetUrl).replace(/\.\./g, '\\$&');
entry = entry.replace(new RegExp(sanitizedUrl, 'img'), escapedMappedUrl);
//NOTE - This code was added to resolve the SRE issue but once the code was merged Assets URLs in JSON RTE started breaking
// const sanitizedUrl = escapeRegExp(assetUrl).replace(/\.\./g, '\\$&');
// const escapedMappedUrl = escapeRegExp(mappedAssetUrl).replace(/\.\./g, '\\$&');
// entry = entry.replace(new RegExp(sanitizedUrl, 'img'), escapedMappedUrl);
entry = entry.replace(new RegExp(assetUrl, 'img'), mappedAssetUrl);
matchedUrls.push(mappedAssetUrl);
} else {
unmatchedUrls.push(assetUrl);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/utils/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const askEncryptionKey = async(defaultValue: unknown): Promise<string> =>

return true;
},
message: 'Enter marketplace app configurations encryption key',
message: 'Enter Marketplace app configurations encryption key',
});
}

Expand Down
22 changes: 12 additions & 10 deletions packages/contentstack-import/src/utils/marketplace-app-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
configHandler,
managementSDKClient,
marketplaceSDKClient,
createDeveloperHubUrl
createDeveloperHubUrl,
} from '@contentstack/cli-utilities';

import { log } from './logger';
Expand Down Expand Up @@ -90,15 +90,17 @@ export const getConfirmationToCreateApps = async (privateApps: any, config: Impo
),
)
) {
return Promise.resolve(true);
}

if (
!(await cliux.confirm(
chalk.yellow('\nWould you like to re-create the private app and then proceed with the installation? (y/n)'),
))
) {
process.exit();
return Promise.resolve(false);
} else {
if (
await cliux.confirm(
chalk.yellow('\nWould you like to re-create the private app and then proceed with the installation? (y/n)'),
)
) {
return Promise.resolve(true);
} else {
return Promise.resolve(false);
}
}
}
}
Expand Down
Loading
Loading