@@ -5,8 +5,7 @@ import { readJsonSync, writeJsonSync } from '@gc-utils/fs-extra';
55import { parse } from 'yaml' ;
66
77const cwd = process . cwd ( ) ;
8- const processPath = join ( cwd , '../' ) ;
9- const projectRootPath = join ( cwd , '../../../' ) ; // project root from current script location
8+ const projectRootPath = join ( cwd , '../../' ) ; // project root from current script location
109
1110const MONOREPO_NAMESPACE = '@slickgrid-universal' ;
1211
@@ -15,8 +14,8 @@ const MONOREPO_NAMESPACE = '@slickgrid-universal';
1514 * with current version from "package.json" package root into "dist/package.json"
1615 */
1716( async function main ( ) {
18- const mainPkg = readJsonSync ( join ( processPath , 'package.json' ) ) ;
19- const distPkg = readJsonSync ( join ( processPath , 'dist' , 'package.json' ) ) ;
17+ const mainPkg = readJsonSync ( join ( cwd , 'package.json' ) ) ;
18+ const distPkg = readJsonSync ( join ( cwd , 'dist' , 'package.json' ) ) ;
2019 const yamlPath = join ( projectRootPath , 'pnpm-workspace.yaml' ) ;
2120
2221 // replace all workspace protocol with current version from "package.json" root into "dist/package.json"
@@ -37,19 +36,19 @@ const MONOREPO_NAMESPACE = '@slickgrid-universal';
3736 }
3837 // otherwise check if it's a local `workspace:` protocol (if so, find associated local dep's version and replace it)
3938 else if ( depName . startsWith ( `${ MONOREPO_NAMESPACE } /` ) || depVersion . startsWith ( 'workspace:' ) ) {
39+ // we need to get each package version
40+ const depPkgName = depName . replace ( MONOREPO_NAMESPACE , '' ) ;
41+ const depPkg = readJsonSync ( join ( cwd , '../../packages/' , depPkgName , 'package.json' ) ) ;
42+
4043 // extra workspace: details, accepts: `workspace:[*~^]` or `workspace:[*~^]1.5.2`
4144 const [ _ , _wsTxt , rangePrefix , semver ] = depVersion . match ( / ^ ( w o r k s p a c e : ) ? ( [ * ~ ^ ] ) ? ( .* ) $ / ) || [ ] ;
4245 const versionPrefix = rangePrefix === '*' ? '' : rangePrefix ;
4346 const finalVersion = semver ? `${ versionPrefix } ${ semver } ` : `${ versionPrefix } ${ depPkg . version } ` ;
44-
45- // we need to get each package version
46- const depPkgName = depName . replace ( MONOREPO_NAMESPACE , '' ) ;
47- const depPkg = readJsonSync ( join ( processPath , '../../packages/' , depPkgName , 'package.json' ) ) ;
48- console . log ( `transformed '${ depVersion } ' → { "${ depName } ": "${ finalVersion } " }` ) ;
4947 distPkg . dependencies [ depName ] = finalVersion ;
48+ console . log ( `transformed '${ depVersion } ' → { "${ depName } ": "${ finalVersion } " }` ) ;
5049 }
5150 }
52- writeJsonSync ( resolve ( processPath , 'dist' , 'package.json' ) , distPkg , { spaces : 2 } ) ;
51+ writeJsonSync ( resolve ( cwd , 'dist' , 'package.json' ) , distPkg , { spaces : 2 } ) ;
5352 console . log ( '-------------------------------------------------------------------------------------\n' ) ;
5453
5554 process . exit ( ) ;
0 commit comments