@@ -25,17 +25,39 @@ if (process.argv[2] == 'tsconfig') {
2525 }
2626
2727 execSync ( `rm -rf ./.yarn/cache/node_modules` )
28-
29- const result = execSync ( `find . -name "@chainlink-external-adapter-framework*"` , {
30- encoding : 'utf-8' ,
31- } )
32-
33- execSync ( `unzip ${ result . trimEnd ( ) } -d ./.yarn/cache` , { maxBuffer : 1024 * 1024 * 500 } )
28+ // This should give either something like 'npm:1.2.3' or
29+ // 'portal:some/local/path:...'
30+ const frameworkVersion = execSync (
31+ `yarn --cwd packages/scripts info @chainlink/external-adapter-framework --json | jq -r '.value'` ,
32+ {
33+ encoding : 'utf-8' ,
34+ } ,
35+ )
36+ . trim ( )
37+ . split ( '@' ) [ 2 ]
38+
39+ let generatorIndexPath = ''
40+
41+ if ( frameworkVersion . startsWith ( 'portal:' ) ) {
42+ generatorIndexPath =
43+ frameworkVersion . split ( ':' ) [ 1 ] + '/generator-adapter/generators/app/index.js'
44+ } else if ( frameworkVersion . startsWith ( 'npm:' ) ) {
45+ const result = execSync (
46+ `find . -name "@chainlink-external-adapter-framework-${ frameworkVersion . replace ( ':' , '-' ) } *"` ,
47+ {
48+ encoding : 'utf-8' ,
49+ } ,
50+ )
51+ execSync ( `unzip ${ result . trimEnd ( ) } -d ./.yarn/cache` , { maxBuffer : 1024 * 1024 * 500 } )
52+
53+ generatorIndexPath =
54+ './.yarn/cache/node_modules/@chainlink/external-adapter-framework/generator-adapter/generators/app/index.js'
55+ } else {
56+ throw new Error ( `Unsupported framework version format: '${ frameworkVersion } '` )
57+ }
3458
3559 execSync ( `npm install -g [email protected] > /dev/null 2>&1` ) 3660
3761 console . log ( 'Run the following command:' )
38- console . log (
39- ` yo ./.yarn/cache/node_modules/@chainlink/external-adapter-framework/generator-adapter/generators/app/index.js ${ path } && yarn new tsconfig` ,
40- )
62+ console . log ( ` yo ${ generatorIndexPath } ${ path } && yarn new tsconfig` )
4163}
0 commit comments