@reflex-stack/tsp 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,15 +72,15 @@ npm run test
72
72
  ```
73
73
  > Will clear `./dist`, build sources and run tests. No size report.
74
74
 
75
- #### Publish
75
+ #### Bump version
76
76
  ```bash
77
- bun run publish
77
+ bun run bump
78
78
  # or
79
- npm run publish
79
+ npm run bump
80
80
  ```
81
81
 
82
- > Will clear `./dist`, build sources, run tests, and start publish process.
83
- > This will ask you how to upgrade package.json version, push to git and npm.
82
+ > Will clear `./dist`, build sources, run tests, and create a new package version.
83
+ > You will be able to run `npm publish --access public` or `bun publish --access public` safely after that.
84
84
 
85
85
 
86
86
  ## Size report
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflex-stack/tsp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tsp": "./src/cli.js"
@@ -13,7 +13,7 @@
13
13
  "./tests": "./src/tests.js"
14
14
  },
15
15
  "scripts": {
16
- "publish": "node ./src/cli.js publish"
16
+ "bump": "node ./src/cli.js bump"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
package/src/cli.js CHANGED
@@ -17,7 +17,7 @@ const commands = new CLICommands({
17
17
 
18
18
  // Executed for all commands
19
19
  commands.before((args, flags, commandName) => {
20
- if ( commandName !== "publish" && !flags.noIntro)
20
+ if ( commandName !== "bump" && !flags.noIntro )
21
21
  showIntroMessage(!commandName || commandName === "init")
22
22
  })
23
23
 
@@ -50,10 +50,11 @@ commands.add("build", async (args, flags) => {
50
50
  task.error()
51
51
  console.log(error.stdout ?? '')
52
52
  console.log(error.stderr ?? '')
53
+ process.exit(1)
53
54
  })
54
55
 
55
56
  // CLI Flag to disable reports and only build
56
- if ( flags.noSizeReport )
57
+ if ( flags && flags.noSizeReport )
57
58
  return
58
59
 
59
60
  // Generate size report
@@ -158,25 +159,26 @@ commands.add("test", async (args, flags, commandName) => {
158
159
  })
159
160
 
160
161
  /**
161
- * PUBLISH COMMAND
162
+ * BUMP VERSION COMMAND
162
163
  */
163
- commands.add("publish", async (args, flags, commandName) => {
164
+ commands.add("bump", async (args, flags, commandName) => {
164
165
  // Check NPM connected user
165
- await oraTask({text: `Connecting to npm`}, async task => {
166
- try {
167
- const whoami = await execAsync(`npm whoami`, 0)
168
- task.success(nicePrint(`Hello {b/c}@${whoami}`, {output: 'return'}).trim())
169
- return whoami
170
- }
171
- catch (e) {
172
- task.error(`Please connect to npm with ${chalk.bold('npm login')}`)
173
- }
174
- })
166
+ // await oraTask({text: `Connecting to npm`}, async task => {
167
+ // try {
168
+ // const whoami = await execAsync(`npm whoami`, 0)
169
+ // task.success(nicePrint(`Hello {b/c}@${whoami}`, {output: 'return'}).trim())
170
+ // return whoami
171
+ // }
172
+ // catch (e) {
173
+ // task.error(`Please connect to npm with ${chalk.bold('npm login')}`)
174
+ // }
175
+ // })
175
176
  // TODO : When test will build only needed files, move build after tests
176
177
  // (to build all files after test has succeed)
177
178
  // Compile
178
- //await CLICommands.run(`build`, cliArguments, cliOptions)
179
- //await CLICommands.run(`test`, cliArguments, cliOptions)
179
+ // await commands.run("build")
180
+ // await commands.run("test")
181
+
180
182
 
181
183
  // todo : Internal build
182
184
  // todo : Run test command
@@ -192,42 +194,33 @@ commands.add("publish", async (args, flags, commandName) => {
192
194
  newLine()
193
195
  nicePrint(`📦 Current version of {b/c}${name}{/} is {b/c}${version}`)
194
196
  // Ask how to increment version
195
- const increment = await askList(`How to increment ?`, {
197
+ const increment = await askList(`How to bump version ?`, {
196
198
  patch: 'patch (0.0.X) - No new features, patch bugs or optimize code',
197
199
  minor: 'minor (0.X.0) - No breaking change, have new or improved features',
198
200
  major: 'major (X.0.0) - Breaking change',
199
- // Keep but publish on NPM (if already increment in package.json)
200
- keep: `keep (${ version }) - Publish current package.json version`,
201
- // Push on git but no lib publish
202
- push: `push - Push on git only, no npm publish`,
203
- // Skip this lib (no publish at all, go to next library)
204
- skip: `skip - Do not publish ${ name }`,
205
201
  }, { returnType: 'key' });
206
- // Go to next library
207
- if ( increment === 'skip' )
208
- return
209
- // execSync(`git status -s`, stdioLevel, libraryExecOptions)
210
- // Ask for commit message
211
- let message = await askInput(`Commit message ?`);
202
+ // Ask for tag message
203
+ let message = await askInput(`Tag message`);
212
204
  message = message.replace(/["']/g, "'");
213
- // If we increment, use npm version
205
+ // // If we increment, use npm version
214
206
  if ( increment !== 'keep' && increment !== 'push' ) {
215
207
  version = execSync(`npm version ${increment} --no-git-tag-version -m"${name} - %s - ${message}"`, stdioLevel, libraryExecOptions).toString().trim();
216
208
  }
217
209
  // Add to git and push
218
- execSync(`git add .`, stdioLevel, libraryExecOptions);
219
- execSync(`git commit -m"${name} - ${version} : ${message}"`, stdioLevel, libraryExecOptions);
220
- execSync(`git push`, stdioLevel, libraryExecOptions);
221
- // Publish on npm as public
222
- // FIXME : Access public as an option for private repositories
223
- // Ingore script to avoid infinite loop (if "package.json.scripts.publish" == "tsbundle publish")
224
- if ( increment !== 'push' ) {
225
- execSync(`npm publish --access public --ignore-scripts`, stdioLevel, libraryExecOptions);
226
- nicePrint(`👌 {b/g}${name}{/}{g} Published, new version is {b/g}${version}`)
227
- }
228
- else {
229
- nicePrint(`👍 {b/g}${name}{/}{g} Pushed to git`)
230
- }
210
+ // execSync(`git add .`, stdioLevel, libraryExecOptions);
211
+ // let prefix = ""
212
+ // if ( increment === 'patch' )
213
+ // prefix = "fix:"
214
+ // else if ( increment === 'minor' )
215
+ // prefix = "feat:"
216
+ // else if ( increment === 'major' )
217
+ // prefix = "major:"
218
+ // execSync(`git commit -m"${prefix}:${name} - ${version} : ${message}"`, stdioLevel, libraryExecOptions);
219
+ // execSync(`git push`, stdioLevel, libraryExecOptions);
220
+ // Ask to publish
221
+ // fixme : should have public or private setting in config
222
+ const packageManager = typeof Bun === "undefined" ? "npm" : "bun"
223
+ nicePrint(`Please run {b/c}${packageManager} publish --access public{/} to publish this library on NPM as a public package.`)
231
224
  })
232
225
 
233
226
 
@@ -54,8 +54,8 @@ For a total of <bundle-size id="total">0b</bundle-size>
54
54
  - \`${runtime} run build\`
55
55
  ##### Test
56
56
  - \`${runtime} run test\`
57
- ##### Publish
58
- - \`${runtime} run publish\`
57
+ ##### Bump version
58
+ - \`${runtime} run bump\`
59
59
 
60
60
  ---
61
61
  ## TSP
@@ -274,7 +274,7 @@ export async function init () {
274
274
  scripts: {
275
275
  build: "tsp build",
276
276
  test: "tsp build --noSizeReport && tsp test --noIntro",
277
- publish: "tsp build && tsp test --noIntro && tsp publish --noIntro"
277
+ bump: "tsp build && tsp test && tsp bump"
278
278
  },
279
279
  dependencies: {
280
280
  "@reflex-stack/tsp": options.tspVersion