Skip to content

Commit 9181463

Browse files
committed
chore: back to working with local add-ons
1 parent df24f72 commit 9181463

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/add-ons.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export async function finalizeAddOns(
100100
let addOn: AddOn | undefined
101101
const localAddOn = addOns.find((a) => a.id === addOnID)
102102
if (localAddOn) {
103-
addOn = localAddOn
103+
addOn = loadAddOn(localAddOn)
104104
} else if (addOnID.startsWith('http')) {
105105
addOn = await loadRemoteAddOn(addOnID)
106106
} else {
@@ -131,12 +131,11 @@ export async function listAddOns(options: CliOptions) {
131131
}
132132
}
133133

134-
function loadAddOn(path: string): AddOn {
135-
const fileContent = await readFile(path, 'utf-8')
136-
return JSON.parse(fileContent)
134+
function loadAddOn(addOn: AddOn): AddOn {
135+
return addOn
137136
}
138137

139-
async function loadRemoteAddOn(url: string): AddOn {
138+
async function loadRemoteAddOn(url: string): Promise<AddOn> {
140139
const response = await fetch(url)
141140
const fileContent = await response.json()
142141
return JSON.parse(fileContent)

src/config-file.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { resolve } from 'node:path'
33

44
import { CONFIG_FILE } from './constants.js'
55

6-
import type { Environment } from './environment'
7-
import type { Options } from './types'
6+
import type { Environment, Options } from './types'
87

98
export type PersistedOptions = Exclude<
109
Partial<Options>,

src/create-app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ async function copyAddOnFile(
251251
environment: Environment,
252252
content: string,
253253
target: string,
254+
targetPath: string,
254255
templateFile: (content: string, targetFileName: string) => Promise<void>,
255256
) {
256257
let targetFile = basename(target).replace(/_dot_/, '.')
@@ -265,8 +266,6 @@ async function copyAddOnFile(
265266
isAppend = true
266267
}
267268

268-
const targetPath = resolve(dirname(target), targetFile)
269-
270269
if (isTemplate) {
271270
await templateFile(content, targetPath)
272271
} else {
@@ -445,10 +444,11 @@ export async function createApp(
445444
s?.start(`Setting up ${addOn.name}...`)
446445
if (addOn.files) {
447446
for (const file of Object.keys(addOn.files)) {
448-
copyAddOnFile(
447+
await copyAddOnFile(
449448
environment,
450449
addOn.files[file],
451450
file,
451+
resolve(targetDir, file),
452452
(content, targetFileName) =>
453453
templateFileFromContent(targetFileName, content),
454454
)

src/package-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Environment } from './environment'
1+
import type { Environment } from './types.js'
22

33
export const SUPPORTED_PACKAGE_MANAGERS = [
44
'npm',

0 commit comments

Comments
 (0)