-
Notifications
You must be signed in to change notification settings - Fork 212
[App Extensibility ⚙️] Support ESLint on Extracted Application Extensions (@W-17373513@) #2192
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
Merged
adamraya
merged 22 commits into
feature/extensibility-v2
from
W-17373513-eslint-application-extensions
Jan 21, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2c94828
Update generator to copy hidden files
adamraya 83527e0
Update pwa-kit-dev lint command to run eslint on app extensions
adamraya 642c418
Support namespaced extensions
adamraya f3ebaf0
clean up
adamraya 97d7215
lint
adamraya 9b8abe6
Add pwa-kit-dev tsc command
adamraya f512cf1
Use pwa-kit-dev tsc
adamraya beb2f97
Update extension tsconfig
adamraya 0138c3b
Fix ts errors
adamraya 2c11134
Clean up debug logs
adamraya 02d3123
clean up
adamraya 35623c7
invert condition
kevinxh ce339c0
Merge branch 'feature/extensibility-v2' into W-17373513-eslint-applic…
adamraya f99a3df
Use NPM workspaces for extracted extensions
adamraya aa0f63d
Revert changes in pwa-kit-dev commands
adamraya 130927a
Update extensions lint script to also run tsc
adamraya 65ccde0
Update generator to add workspaces
adamraya ec5ea34
Conditionally add workspaces for extractAppExtensions
adamraya 559a344
Revert "Update extensions lint script to also run tsc"
adamraya 9381677
PR Feedback
adamraya f65d5ad
Split APP_EXTENSIONS_DIR into two constants
adamraya 16c53bd
Fix typo in APP_DIR
adamraya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
packages/extension-chakra-store-locator/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,5 +37,9 @@ | |
|
|
||
| /* Completeness */ | ||
| "skipLibCheck": true | ||
| } | ||
| }, | ||
| "exclude": [ | ||
| "node_modules", | ||
| "static" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -564,8 +564,12 @@ const ALL_PRESET_NAMES = PRIVATE_PRESET_NAMES.concat(PUBLIC_PRESET_NAMES) | |
|
|
||
| const PROJECT_ID_MAX_LENGTH = 20 | ||
|
|
||
| // Utilities | ||
| // Constant for the base application directory | ||
| const APP_DIR = 'app' | ||
| // Constant for the directory containing extracted application extensions | ||
| const APP_EXTENSIONS_DIR = 'application-extensions' | ||
|
|
||
| // Utilities | ||
| const readJson = (path) => JSON.parse(sh.cat(path)) | ||
|
|
||
| const writeJson = (path, data) => new sh.ShellString(JSON.stringify(data, null, 2)).to(path) | ||
|
|
@@ -775,11 +779,11 @@ const processTemplate = (relFile, inputDir, outputDir, context) => { | |
| } | ||
|
|
||
| /** | ||
| * Process the Application Extensions into the application-extensions directory. | ||
| * Process the Application Extensions into the extracted application extensions directory. | ||
| * | ||
| * @param appExtensions - An array of the Application Extension names. | ||
| * @param extractAppExtensions - A boolean indicating whether to extract the Application Extensions code from the npm package | ||
| * @param appExtensionsDir - The path to the application-extensions directory. | ||
| * @param {Array} appExtensions - An array of the Application Extension names. | ||
| * @param {boolean} extractAppExtensions - A boolean indicating whether to extract the Application Extensions code from the npm package. | ||
| * @param {string} appExtensionsDir - The path to the extracted application extensions directory. | ||
| */ | ||
| const processAppExtensions = ( | ||
| appExtensions = [], | ||
|
|
@@ -806,11 +810,14 @@ const processAppExtensions = ( | |
| sync: true | ||
| }) | ||
|
|
||
| // Copy the Application Extension into the appropriate folder inside application-extensions | ||
| // Copy the extracted Application Extension into the appropriate folder | ||
| const appExtensionTmpPath = p.join(appExtensionTmp, 'package') | ||
| const appExtensionDestDir = p.join(appExtensionsDir, appExtensionName) | ||
| const appExtensionDestDir = p.join(appExtensionsDir, appExtensionName.replace('/', '_')) | ||
| sh.mkdir('-p', appExtensionDestDir) | ||
|
|
||
| // Copy hidden files | ||
| sh.cp('-rf', p.join(appExtensionTmpPath, '.*'), appExtensionDestDir) | ||
| // Copy regular files | ||
|
Comment on lines
+818
to
+820
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noice |
||
| sh.cp('-rf', p.join(appExtensionTmpPath, '*'), appExtensionDestDir) | ||
|
|
||
| // Clean up the temporary Application Extension directory | ||
|
|
@@ -874,7 +881,7 @@ const runGenerator = async ( | |
| // downloading from NPM or copying from the template bundle folder. | ||
| const tmp = fs.mkdtempSync(p.resolve(os.tmpdir(), 'extract-template')) | ||
| const packagePath = p.join(tmp, 'package') | ||
| const appExtensionsDir = p.join(outputDir, 'app', 'application-extensions') | ||
| const appExtensionsDir = p.join(outputDir, APP_DIR, APP_EXTENSIONS_DIR) | ||
| const {id, type} = templateSource | ||
| let tarPath | ||
|
|
||
|
|
@@ -985,25 +992,36 @@ const runGenerator = async ( | |
| processAppExtensions(selectedAppExtensions, extractAppExtensions, appExtensionsDir) | ||
| } | ||
|
|
||
| // Add selected Application Extensions to devDependencies | ||
| const appExtensionDeps = selectedAppExtensions.reduce((acc, appExtensionName) => { | ||
| // Find the corresponding Application Extension details | ||
| const appExtensionDetails = context?.availableAppExtensions?.find( | ||
| (ext) => ext.value === `${appExtensionName}@latest` | ||
| ) | ||
| const version = appExtensionDetails ? appExtensionDetails.version : 'latest' | ||
|
|
||
| acc[appExtensionName] = extractAppExtensions | ||
| ? `file:./app/application-extensions/${appExtensionName}` | ||
| : version | ||
| return acc | ||
| }, {}) | ||
|
|
||
| updatePackageJson(p.resolve(outputDir, 'package.json'), { | ||
| // Prepare updates for package.json | ||
| const pkgUpdates = { | ||
| name: getSlugifiedProjectName(context.answers.project.name || context.preset.id), | ||
| version: GENERATED_PROJECT_VERSION, | ||
| devDependencies: appExtensionDeps | ||
| }) | ||
| // Conditionally add workspaces for extractAppExtensions | ||
| ...(extractAppExtensions && { | ||
| workspaces: [`${p.join(APP_DIR, APP_EXTENSIONS_DIR)}/*`] | ||
| }), | ||
| // Add selected Application Extensions to devDependencies | ||
| devDependencies: selectedAppExtensions.reduce((acc, appExtensionName) => { | ||
| // Find the corresponding Application Extension details | ||
| const appExtensionDetails = context?.availableAppExtensions?.find( | ||
| (ext) => ext.value === `${appExtensionName}@latest` | ||
| ) | ||
| const version = appExtensionDetails ? appExtensionDetails.version : 'latest' | ||
|
|
||
| acc[appExtensionName] = extractAppExtensions | ||
| ? `file:${p.join( | ||
| '.', | ||
| APP_DIR, | ||
| APP_EXTENSIONS_DIR, | ||
| appExtensionName.replace('/', '_') | ||
| )}` | ||
| : version | ||
| return acc | ||
| }, {}) | ||
| } | ||
|
|
||
| // Update the root package.json | ||
| updatePackageJson(p.resolve(outputDir, 'package.json'), pkgUpdates) | ||
|
|
||
| // Clean up the temporary directory | ||
| sh.rm('-rf', tmp) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will this work on windows?
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.
Yes, I tested it on Windows, and it works well.