Skip to content

Commit

Permalink
Merge branch 'main' of github.com:adobecom/mas into MWPW-162020
Browse files Browse the repository at this point in the history
  • Loading branch information
yesil committed Jan 10, 2025
2 parents 730496b + 4c12a86 commit e498d50
Show file tree
Hide file tree
Showing 59 changed files with 3,751 additions and 2,230 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
4 changes: 2 additions & 2 deletions k6-scripts/fragment-fetches.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default function () {
} else {
const fields = res?.body?.length > 0 ? JSON.parse(res.body).fields : {};
const fieldCheck = check(fields, {
'cardTitle is not empty': (f) => {
return f?.cardTitle?.length > 0;
'description is not empty': (f) => {
return f?.description?.value?.length > 0;
},
});
if (!fieldCheck) {
Expand Down
26 changes: 26 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# gen-locales.mjs

## Description
The `gen-locales.mjs` script is used to generate locale content tree for a MAS sub tenant in Odin.

## Usage

### Prerequisites
- Node.js installed on your machine

- Required environment variables:
- `accessToken`: The IMS access token of a user, copy it from your IMS session in MAS Studio.
- `apiKey`: The API key for authentication, api key used in MAS Studio.

- Required parameters:
- `bucket`: The AEM bucket name, e.g: author-p22655-e155390 for Odin QA
- `consumer`: The consumer identifier, e.g: ccd

### Running the Script
3. Run the script:
```sh
export accessToken="your-access-token"
export apiKey="your-api-key"

node gen-locales.mjs author-p22655-e155390 drafts
```
117 changes: 117 additions & 0 deletions scripts/gen-locales.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import https from 'https';

/**
* This script creates locale tree for the locales below for a given bucket(env) and consumer in Odin.
* e.g: node gen-locales.mjs author-p22655-e155390 drafts
*/

const locales = [
'cs_CZ',
'da_DK',
'es_ES',
'fi_FI',
'hu_HU',
'id_ID',
'it_IT',
'ko_KR',
'nb_NO',
'nl_NL',
'pl_PL',
'pt_BR',
'ru_RU',
'sv_SE',
'th_TH',
'tr_TR',
'uk_UA',
'vi_VN',
'zh_CN',
'zh_TW',
'ja_JP',
'de_DE',
'es_MX',
'fr_CA',
'fr_FR',
'en_US', // displayed first in AEM by default
];

const args = process.argv.slice(2);
const bucket = args[0];
const consumer = args[1];

const accessToken = process.env.MAS_ACCESS_TOKEN;
const apiKey = process.env.MAS_API_KEY;

if (!bucket || !consumer || !accessToken || !apiKey) {
console.error('Usage: node gen-locales.mjs <bucket> <consumer>');
console.error(
'Ensure MAS_ACCESS_TOKEN and MAS_API_KEY are set as environment variables.',
);
process.exit(1);
}

async function run() {
const batchSize = 5;
for (let i = 0; i < locales.length; i += batchSize) {
const batch = locales.slice(i, i + batchSize).map((locale) => ({
path: `/content/dam/mas/${consumer}/${locale}`,
title: locale,
}));

const options = {
hostname: `${bucket}.adobeaemcloud.com`,
path: '/adobe/folders/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Adobe-Accept-Experimental': '1',
Authorization: `Bearer ${accessToken}`,
'x-api-key': apiKey,
},
};

await new Promise((resolve, reject) => {
const req = https.request(options, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
if (res.statusCode >= 200 && res.statusCode < 300) {
console.log(
`Batch processed successfully: ${JSON.stringify(batch)}`,
);
resolve();
} else {
console.error(
`Failed to process batch: ${JSON.stringify(batch)}`,
res.statusCode,
data,
);
reject(
new Error(
`Failed to process batch: ${res.statusCode}`,
),
);
}
});
});

req.on('error', (error) => {
console.error(
`Error processing batch: ${JSON.stringify(batch)}`,
error,
);
reject(error);
});

req.write(JSON.stringify(batch));
req.end();
});
}

console.log('All batches processed.');
}

run();
18 changes: 9 additions & 9 deletions studio/libs/prosemirror.js

Large diffs are not rendered by default.

747 changes: 443 additions & 304 deletions studio/libs/swc.js

Large diffs are not rendered by default.

Loading

0 comments on commit e498d50

Please sign in to comment.