-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix(sites-29590): support user bearer token #22
Conversation
export async function uploadAssets(target, token, assetFolder, fileUploader = null) { | ||
const fileUpload = fileUploader || createFileUploader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One doubt: why are we allowing a fileUploader
instance to be passed, since this is an implementation details which consumer should not have access to.
Also, in case the consumer passes a random value (since the type definition is not explicit) here it will break the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the fileUploader allows me to test the fact that it was uploaded. This is a super weird/hard function to test. Do you see any other way of testing this?
let assetPath = path.join(downloadFolder, jcrPath.replace(CONTENT_DAM_PREFIX, '')); | ||
fs.mkdirSync(path.dirname(assetPath), { recursive: true }); | ||
|
||
const buffer = Buffer.from(await blob.arrayBuffer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, your implementation is so much simpler! 🥇
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) { | ||
const file = new File([fs.readFileSync(packagePath)], 'file'); | ||
const formData = new FormData(); | ||
formData.set('install', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so we can directly install a package, without having to upload it first! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that. One thing that continues to mess things up is the index page on reinstalls. There's a install issue due to nodes being present iirc. Once I delete the index page then it installed fine.
* @return {Promise<Array<PromiseSettledResult<string>>>} A promise that resolves when all assets are downloaded. | ||
* Each promise in the array will resolve with the JCR path of the downloaded asset. | ||
*/ | ||
export async function downloadAssets(assetMapping, downloadFolder, maxRetries = 3,retryDelay = 5000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export async function downloadAssets(assetMapping, downloadFolder, maxRetries = 3,retryDelay = 5000) { | |
export async function downloadAssets(assetMapping, downloadFolder, maxRetries = 3, retryDelay = 5000) { |
- Should the
maxRetries
also be read from theprocess.env.MAX_RETRIES
(similar to how it is done in package-helper.js)? - Same for the
retryDelay
should be just declare a const and not have it as an input (to keep the method signatures consistent)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I think no one is going to mess with those environment variables. If it doesn't work after a specific number of tries, there's something wrong.
|
||
Run the following command to upload content package (JCR pages) and associated assets to your AEM author: | ||
|
||
``` | ||
npm run aem-upload -- --zip /path/to/zip.zip --asset-mapping /path/to/asset-mapping.json | ||
npm run aem-upload -- \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const scope = nock('http://www.aem.com') | ||
.get('/asset1.jpg') | ||
.replyWithFile(200, path.resolve(__dirname, 'fixtures/image1.jpeg')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Makes mocking api calls so much cleaner. clap-clap
# 1.0.0 (2025-03-11) ### Bug Fixes * Add unit test coverage ([#6](#6)) ([16b6146](16b6146)) * Figure out asset folder name from jcr image path ([#15](#15)) ([461292c](461292c)) * **sites-29589:** [Xwalk] aem-import-helper should take zip file and image mapping as args ([#20](#20)) ([2c1c615](2c1c615)) * **sites-29590:** support user bearer token ([#22](#22)) ([4d190b1](4d190b1)) ### Features * [Import Assistant] Page transformations ([#4](#4)) ([bfacdb0](bfacdb0)) * Implement standalone upload command ([72fd15d](72fd15d)) * Import Assistant ([#7](#7)) ([05e2082](05e2082)) * Initial implementation of SharePoint upload ([00eb93a](00eb93a)) * Initial implementation of SharePoint upload ([6cfc248](6cfc248)) * Initial implementation of SharePoint upload ([927d7eb](927d7eb)) * Initial implementation of SharePoint upload ([cc5a4b1](cc5a4b1)) * Show UI URL when job was created ([#13](#13)) ([04db418](04db418)) * SITES-27041 [Import Assistant] Remove system prompts from import builder ([#9](#9)) ([978a68d](978a68d)) * **sites-29400:** integrate xwalk support into aem-import-helper ([#17](#17)) ([e4e3afd](e4e3afd)) * **sites-29416:** [Xwalk] Add support for importing non-image assets ([#19](#19)) ([3c6c87d](3c6c87d)) * SITES-29655 Remove import assistant related code from the helper ([823c56a](823c56a)) * SITES-29655 Remove import assistant related code from the helper ([c3caac0](c3caac0)) * SITES-29655 Remove import assistant related code from the helper ([7f262e1](7f262e1)) * Upload content to AEM ([#11](#11)) ([6140cf1](6140cf1)) * Use multipart formdata to start a job ([#3](#3)) ([852d96d](852d96d))
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.