11( async ( ) => {
2- // const chalk = require('chalk')
3- // const execa = require('execa')
42 const path = require ( 'path' )
53 const semanticRelease = require ( 'semantic-release' )
6- // const { WritableStreamBuffer } = require('stream-buffers');
7- // const stdoutBuffer = WritableStreamBuffer();
8- // const stderrBuffer = WritableStreamBuffer();
94
105 const args = require ( 'minimist' ) ( process . argv . slice ( 2 ) )
116 const target = args . _ [ 0 ]
2419 [
2520 '@semantic-release/exec' ,
2621 {
27- prepareCmd : 'npx ts-node ../../scripts/build.ts --nextVersion ${nextRelease.version}' ,
28- publishCmd : `zip ${ target } -dist.zip -r dist` ,
22+ prepareCmd : `npx ts-node ../../scripts/build.ts --nextVersion \$\{nextRelease.version\} && zip ${ target } -dist.zip -r dist` ,
2923 }
3024 ] ,
3125 '@semantic-release/npm' ,
4438 ]
4539 }
4640
47- await run ( )
41+ run ( )
4842
4943 async function run ( ) {
50- // const nextVersion = await getNextVersion()
51- // console.log(nextVersion)
52- // await prepare(target)
53- await release ( )
54- }
55-
56- // async function prepare(target: string/*, nextVersion: string*/) {
57- // try {
58- // // const buildScript = path.resolve(__dirname, 'build.ts')
59- // // console.log(chalk.bgCyan("Build package"))
60- // // execa.sync('npx', ['ts-node', buildScript, '--nextVersion', nextVersion])
61- // console.log(chalk.bgCyan("Zipping distribution file"))
62- // execa.sync('zip', ['-r', `${target}-dist.zip`, '.', '-i', 'dist'])
63- // } catch (err) {
64- // console.log(`>>>>>>>>>>>>> ${err}`)
65- // }
66- // }
67-
68- async function release ( ) {
69- // const pkgDir = path.resolve(__dirname, '..')
44+ const pkgDir = path . resolve ( __dirname , `../packages/${ target } ` )
7045 try {
71- console . log ( `>>>>>>>>>>>>> Semantic release ` )
46+ console . log ( `\n >>>>>>>>>>>>>>>>>>>> SEMANTIC RELEASE <<<<<<<<<<<<<<<<<<<<\n ` )
7247 const result = await semanticRelease ( {
73- // Core options
7448 branches : releaserc . branches ,
7549 repositoryUrl : pkg . repository . url ,
7650 plugins : releaserc . plugins
7751 } , {
78- // Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
79- cwd : '' ,
80- // Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
81- env : { ...process . env } ,
82- // Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
83- // stdout: stdoutBuffer,
84- // stderr: stderrBuffer
52+ cwd : pkgDir ,
53+ env : { ...process . env }
8554 } ) ;
8655
8756 if ( result ) {
88- console . log ( `>>>>>>>>>>>>> Result ` )
57+ console . log ( `\n >>>>>>>>>>>>>>>>>>>> RELEASE RESULT <<<<<<<<<<<<<<<<<<<<\n ` )
8958 const { lastRelease, commits, nextRelease, releases } = result ;
9059
9160 console . log ( `Published ${ nextRelease . type } release version ${ nextRelease . version } containing ${ commits . length } commits.` ) ;
10170 console . log ( 'No release published.' ) ;
10271 }
10372
104- // Get stdout and stderr content
105- // const logs = stdoutBuffer.getContentsAsString('utf8');
106- // const errors = stderrBuffer.getContentsAsString('utf8');
107- // console.log(logs, errors);
108-
10973 } catch ( err ) {
11074 console . error ( 'The automated release failed with %O' , err )
11175 }
11276 }
113-
114- // async function getNextVersion(): Promise<string> {
115- // const rootDir = path.resolve(__dirname, '..')
116- // try {
117- // const { nextRelease } = await semanticRelease({
118- // branches: releaserc.branches,
119- // repositoryUrl: pkg.repository.url,
120- // plugins: [
121- // '@semantic-release/commit-analyzer',
122- // [
123- // "@semantic-release/exec",
124- // {
125- // prepareCmd: "npx ts-node scripts/build.ts --nextVersion ${nextRelease.version}"
126- // }
127- // ]
128- // ]
129- // }, {
130- // cwd: rootDir,
131- // env: { ...process.env }
132- // })
133- // if (nextRelease) return nextRelease.version
134- // else console.log('No release will bepublished')
135- // } catch (err) {
136- // console.error('Failed to retrieve next version with %O', err)
137- // }
138- // return pkg.version
139- // }
14077} ) ( )
0 commit comments