File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export async function finalizeAddOns(
100
100
let addOn : AddOn | undefined
101
101
const localAddOn = addOns . find ( ( a ) => a . id === addOnID )
102
102
if ( localAddOn ) {
103
- addOn = localAddOn
103
+ addOn = loadAddOn ( localAddOn )
104
104
} else if ( addOnID . startsWith ( 'http' ) ) {
105
105
addOn = await loadRemoteAddOn ( addOnID )
106
106
} else {
@@ -131,12 +131,11 @@ export async function listAddOns(options: CliOptions) {
131
131
}
132
132
}
133
133
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
137
136
}
138
137
139
- async function loadRemoteAddOn ( url : string ) : AddOn {
138
+ async function loadRemoteAddOn ( url : string ) : Promise < AddOn > {
140
139
const response = await fetch ( url )
141
140
const fileContent = await response . json ( )
142
141
return JSON . parse ( fileContent )
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ import { resolve } from 'node:path'
3
3
4
4
import { CONFIG_FILE } from './constants.js'
5
5
6
- import type { Environment } from './environment'
7
- import type { Options } from './types'
6
+ import type { Environment , Options } from './types'
8
7
9
8
export type PersistedOptions = Exclude <
10
9
Partial < Options > ,
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ async function copyAddOnFile(
251
251
environment : Environment ,
252
252
content : string ,
253
253
target : string ,
254
+ targetPath : string ,
254
255
templateFile : ( content : string , targetFileName : string ) => Promise < void > ,
255
256
) {
256
257
let targetFile = basename ( target ) . replace ( / _ d o t _ / , '.' )
@@ -265,8 +266,6 @@ async function copyAddOnFile(
265
266
isAppend = true
266
267
}
267
268
268
- const targetPath = resolve ( dirname ( target ) , targetFile )
269
-
270
269
if ( isTemplate ) {
271
270
await templateFile ( content , targetPath )
272
271
} else {
@@ -445,10 +444,11 @@ export async function createApp(
445
444
s ?. start ( `Setting up ${ addOn . name } ...` )
446
445
if ( addOn . files ) {
447
446
for ( const file of Object . keys ( addOn . files ) ) {
448
- copyAddOnFile (
447
+ await copyAddOnFile (
449
448
environment ,
450
449
addOn . files [ file ] ,
451
450
file ,
451
+ resolve ( targetDir , file ) ,
452
452
( content , targetFileName ) =>
453
453
templateFileFromContent ( targetFileName , content ) ,
454
454
)
Original file line number Diff line number Diff line change 1
- import type { Environment } from './environment '
1
+ import type { Environment } from './types.js '
2
2
3
3
export const SUPPORTED_PACKAGE_MANAGERS = [
4
4
'npm' ,
You can’t perform that action at this time.
0 commit comments