Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
116 changes: 116 additions & 0 deletions 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.

4 changes: 3 additions & 1 deletion packages/extension-chakra-store-locator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint": "npm run lint:js",
"lint:fix": "npm run lint:js -- --fix",
"test": "pwa-kit-dev test",
"lint:js": "pwa-kit-dev lint \"**/*.{js,jsx,ts,tsx}\""
"lint:js": "pwa-kit-dev lint \"**/*.{js,jsx,ts,tsx}\"",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"@chakra-ui/react": "^2",
Expand Down Expand Up @@ -60,6 +61,7 @@
"@salesforce/pwa-kit-runtime": "4.0.0-extensibility-preview.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/express": "^5.0.0",
"@types/react": "~18.2.0",
"@types/react-dom": "~18.2.1",
"@types/react-router-dom": "^5.3.3",
Expand Down
9 changes: 7 additions & 2 deletions packages/extension-chakra-store-locator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"paths": {
"overridable!./*": [
"src/*",
"src/components/*",
"node_modules/@salesforce/extension-*"
]
},
Expand All @@ -37,5 +38,9 @@

/* Completeness */
"skipLibCheck": true
}
}
},
"exclude": [
"node_modules",
"static"
]
}
3 changes: 2 additions & 1 deletion packages/extension-chakra-storefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint": "npm run lint:js",
"lint:fix": "npm run lint:js -- --fix",
"lint:js": "pwa-kit-dev lint \"**/*.{js,jsx,ts,tsx}\"",
"test": "pwa-kit-dev test"
"test": "pwa-kit-dev test",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"@chakra-ui/icons": "^2.0.19",
Expand Down
6 changes: 5 additions & 1 deletion packages/extension-chakra-storefront/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@

/* Completeness */
"skipLibCheck": true
}
},
"exclude": [
"node_modules",
"static"
]
}
68 changes: 43 additions & 25 deletions packages/pwa-kit-create-app/scripts/create-mobify-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = [],
Expand All @@ -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('/', '_'))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

sh.mkdir('-p', appExtensionDestDir)

// Copy hidden files
sh.cp('-rf', p.join(appExtensionTmpPath, '.*'), appExtensionDestDir)
// Copy regular files
Comment on lines +818 to +820
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Loading