Skip to content

Commit 8865419

Browse files
committed
refactor: rename import-map file to head.import-map
1 parent 919d4fe commit 8865419

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/commands/theme/component/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* - Maps the components in the theme directory
55
* - Copies rendered component files (snippets and assets) into the theme directory
66
* - Cleans up unnecessary component files in the theme directory
7-
* - Generates an import-map.liquid snippet file based on JS assets
7+
* - Generates a head.import-map.liquid snippet file based on JS assets
88
*/
99

1010
import Args from '../../../utilities/args.js'

src/commands/theme/generate/import-map.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* - Reads all JS files in the assets directory
55
* - Creates an import map object with the asset URLs
6-
* - Writes the import map to snippets/import-map.liquid
6+
* - Writes the import map to snippets/head.import-map.liquid
77
*/
88

99
import * as fs from 'node:fs'
@@ -50,15 +50,15 @@ export default class GenerateImportMap extends BaseCommand {
5050
)
5151
}
5252

53-
// Write the import map to snippets/import-map.liquid
53+
// Write the import map to snippets/head.import-map.liquid
5454
const importMapContent = `<script type="importmap">\n${JSON.stringify(importMap, null, 2)}\n</script>`
55-
const importMapPath = path.join(snippetsDir, 'import-map.liquid')
55+
const importMapPath = path.join(snippetsDir, 'head.import-map.liquid')
5656
if (!fs.existsSync(importMapPath) || fs.readFileSync(importMapPath, 'utf8') !== importMapContent) {
5757
fs.writeFileSync(importMapPath, importMapContent)
5858
}
5959

6060
if (!this.flags[Flags.QUIET]) {
61-
this.log('Successfully generated import map at snippets/import-map.liquid')
61+
this.log('Successfully generated import map at snippets/head.import-map.liquid')
6262
}
6363
}
6464
}

test/commands/theme/generate/import-map.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ describe('theme generate import-map', () => {
2222

2323
it('generates empty import map when no JS files exist', async () => {
2424
await runCommand(['theme:generate:import-map', testThemePath])
25-
26-
const importMapPath = path.join(testThemePath, 'snippets', 'import-map.liquid')
25+
26+
const importMapPath = path.join(testThemePath, 'snippets', 'head.import-map.liquid')
2727
const content = fs.readFileSync(importMapPath, 'utf8')
28-
28+
2929
const jsonContent = extractImportMapJson(content)
3030
expect(jsonContent).to.deep.equal({
3131
imports: {}
@@ -36,12 +36,12 @@ describe('theme generate import-map', () => {
3636
const assetsPath = path.join(testThemePath, 'assets')
3737
fs.writeFileSync(path.join(assetsPath, 'main.js'), '')
3838
fs.writeFileSync(path.join(assetsPath, 'utils.js'), '')
39-
39+
4040
await runCommand(['theme:generate:import-map', testThemePath])
41-
42-
const importMapPath = path.join(testThemePath, 'snippets', 'import-map.liquid')
41+
42+
const importMapPath = path.join(testThemePath, 'snippets', 'head.import-map.liquid')
4343
const content = fs.readFileSync(importMapPath, 'utf8')
44-
44+
4545
const jsonContent = extractImportMapJson(content)
4646
expect(jsonContent).to.deep.equal({
4747
imports: {
@@ -54,12 +54,12 @@ describe('theme generate import-map', () => {
5454
it('does not include .min in the entry key', async () => {
5555
const assetsPath = path.join(testThemePath, 'assets')
5656
fs.writeFileSync(path.join(assetsPath, 'component.min.js'), '')
57-
57+
5858
await runCommand(['theme:generate:import-map', testThemePath])
59-
60-
const importMapPath = path.join(testThemePath, 'snippets', 'import-map.liquid')
59+
60+
const importMapPath = path.join(testThemePath, 'snippets', 'head.import-map.liquid')
6161
const content = fs.readFileSync(importMapPath, 'utf8')
62-
62+
6363
const jsonContent = extractImportMapJson(content)
6464
expect(jsonContent).to.deep.equal({
6565
imports: {
@@ -90,12 +90,12 @@ describe('theme generate import-map', () => {
9090
it('updates existing import map', async () => {
9191
const assetsPath = path.join(testThemePath, 'assets')
9292
fs.writeFileSync(path.join(assetsPath, 'main.js'), '')
93-
const importMapPath = path.join(testThemePath, 'snippets', 'import-map.liquid')
93+
const importMapPath = path.join(testThemePath, 'snippets', 'head.import-map.liquid')
9494
const initialContent = `<script type="importmap">\n{\n "imports": {}\n}\n</script>`
9595
fs.writeFileSync(importMapPath, initialContent)
9696

9797
await runCommand(['theme:generate:import-map', testThemePath])
98-
98+
9999
const content = fs.readFileSync(importMapPath, 'utf8')
100100
const jsonContent = extractImportMapJson(content)
101101
expect(jsonContent).to.deep.equal({

0 commit comments

Comments
 (0)