1
- import fs from 'fs' ;
2
- import path from 'path' ;
3
- import chalk from 'chalk' ;
4
- import semver from 'semver' ;
5
- import { execa } from 'execa' ;
6
- import { cwd } from 'process' ;
7
- import enquirer from 'enquirer' ;
1
+ 'use strict' ;
8
2
9
- const { prompt } = enquirer ;
10
- const currentVersion = JSON . parse ( fs . readFileSync ( path . resolve ( cwd ( ) , 'package.json' ) , 'utf-8' ) ) . version ;
11
- const versionIncrements = [ 'patch' , 'minor' , 'major' ] ;
3
+ const fs = require ( 'fs' ) ;
4
+ const path = require ( 'path' ) ;
5
+ const semver = require ( 'semver' ) ;
6
+ const { cwd } = require ( 'process' ) ;
7
+ const enquirer = require ( 'enquirer' ) ;
12
8
13
- const inc = ( i ) => semver . inc ( currentVersion , i ) ;
14
- const run = async ( bin , args , opts = { } ) => {
15
- try {
16
- await execa ( bin , args , { stdio : 'inherit' , ...opts } ) ;
17
- } catch ( err ) {
18
- console . error ( chalk . red ( `Error running command: ${ bin } ${ args . join ( ' ' ) } ` ) ) ;
19
- console . error ( err . message ) ;
20
- process . exit ( 1 ) ;
21
- }
22
- } ;
23
- const step = ( msg ) => console . log ( chalk . cyan ( msg ) ) ;
9
+ const { prompt } = enquirer ;
24
10
25
11
async function main ( ) {
12
+ const chalk = ( await import ( 'chalk' ) ) . default ; // Importação dinâmica para ESM
13
+ const { execa } = await import ( 'execa' ) ; // Importação dinâmica para ESM
14
+
15
+ const currentVersion = JSON . parse ( fs . readFileSync ( path . resolve ( cwd ( ) , 'package.json' ) , 'utf-8' ) ) . version ;
16
+ const versionIncrements = [ 'patch' , 'minor' , 'major' ] ;
17
+
18
+ const inc = ( i ) => semver . inc ( currentVersion , i ) ;
19
+ const run = async ( bin , args , opts = { } ) => {
20
+ try {
21
+ await execa ( bin , args , { stdio : 'inherit' , ...opts } ) ;
22
+ } catch ( err ) {
23
+ console . error ( chalk . red ( `Error running command: ${ bin } ${ args . join ( ' ' ) } ` ) ) ;
24
+ console . error ( err . message ) ;
25
+ process . exit ( 1 ) ;
26
+ }
27
+ } ;
28
+ const step = ( msg ) => console . log ( chalk . cyan ( msg ) ) ;
29
+
26
30
let targetVersion ;
27
31
28
32
try {
@@ -89,11 +93,7 @@ async function main() {
89
93
90
94
// Publish the package
91
95
step ( '\nPublishing the package...' ) ;
92
- await run ( 'npm' , [
93
- 'publish' ,
94
- '--access' ,
95
- 'public' ,
96
- ] ) ;
96
+ await run ( 'pnpm' , [ 'publish' , '--access' , 'public' ] ) ;
97
97
98
98
// Push changes to GitHub
99
99
step ( '\nPushing to GitHub...' ) ;
@@ -115,11 +115,11 @@ function updatePackage(version) {
115
115
pkg . version = version ;
116
116
117
117
fs . writeFileSync ( pkgPath , JSON . stringify ( pkg , null , 4 ) + '\n' ) ;
118
- step ( `Updated package.json version to ${ version } ` ) ;
118
+ console . log ( `Updated package.json version to ${ version } ` ) ;
119
119
}
120
120
121
121
main ( ) . catch ( ( err ) => {
122
- console . error ( chalk . red ( `\nUnexpected error:` ) ) ;
122
+ console . error ( `\nUnexpected error:` ) ;
123
123
console . error ( err . message ) ;
124
124
process . exit ( 1 ) ;
125
125
} ) ;
0 commit comments