Skip to content

Commit

Permalink
Update postinstall script to remove importmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 committed Jul 25, 2024
1 parent 58c3078 commit 81aaccf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
19 changes: 19 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ fs.readdirSync('node_modules/@dropins', { withFileTypes: true }).forEach((file)
});
});

function updateImports(dir) {
fs.readdirSync(dir, { withFileTypes: true }).forEach((file) => {
const filePath = path.join(dir, file.name);
if (file.isDirectory()) {
updateImports(filePath);
}
if (file.isFile() && file.name.endsWith('.js')) {
let content = fs.readFileSync(filePath, 'utf8');

// In content replace all occurences of @dropins with /scripts/__dropins__
content = content.replaceAll('@dropins/', '/scripts/__dropins__/');
fs.writeFileSync(filePath, content);
}
});
}

// Update imports in dropins
updateImports(dropinsDir);

fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-event-collector/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-collector.js'));
fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-events-sdk/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-sdk.js'));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Initializer } from '/scripts/__dropins__/tools/types/elsie/src/lib';
import { Lang } from '/scripts/__dropins__/tools/types/elsie/src/i18n';
import { Initializer } from '@dropins/tools/types/elsie/src/lib';
import { Lang } from '@dropins/tools/types/elsie/src/i18n';
import { ProductModel } from '../../data/models';

type ConfigProps = {
Expand All @@ -14,6 +14,6 @@ type ConfigProps = {
};
};
export declare const initialize: Initializer<ConfigProps>;
export declare const config: import('/scripts/__dropins__/tools/types/elsie/src/lib').Config<ConfigProps>;
export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
export {};
//# sourceMappingURL=initialize.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { HTMLAttributes } from 'preact/compat';
import { Container, SlotProps, SlotMethod, ResolveImageUrlOptions } from '/scripts/__dropins__/tools/types/elsie/src/lib';
import { ButtonProps } from '/scripts/__dropins__/tools/types/elsie/src/components';
import { Container, SlotProps, SlotMethod, ResolveImageUrlOptions } from '@dropins/tools/types/elsie/src/lib';
import { ButtonProps } from '@dropins/tools/types/elsie/src/components';
import { ProductModel } from '../../data/models';

type IconType = keyof typeof import('/scripts/__dropins__/tools/types/elsie/src/icons');
type IconType = keyof typeof import('@dropins/tools/types/elsie/src/icons');
type Values = {
sku: string;
quantity: number;
Expand Down
2 changes: 1 addition & 1 deletion scripts/__dropins__/storefront-pdp/render/render.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Render } from '/scripts/__dropins__/tools/types/elsie/src/lib';
import { Render } from '@dropins/tools/types/elsie/src/lib';

export declare const render: Render;
//# sourceMappingURL=render.d.ts.map

0 comments on commit 81aaccf

Please sign in to comment.