@traceletdev/next 0.5.0 → 0.5.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
@@ -15,7 +15,7 @@ After installing, add a postbuild script to your `package.json`:
15
15
  ```json
16
16
  {
17
17
  "scripts": {
18
- "postbuild": "node node_modules/@traceletdev/next/collect.js"
18
+ "postbuild": "tracelet-next collect"
19
19
  }
20
20
  }
21
21
  ```
@@ -24,7 +24,7 @@ Or run manually after building:
24
24
 
25
25
  ```bash
26
26
  npm run build
27
- node node_modules/@traceletdev/next/collect.js
27
+ npx tracelet-next collect
28
28
  ```
29
29
 
30
30
  This will generate `.tracelet/stats.json` which is used by `tracelet lint` to check performance budgets.
package/cli.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const command = process.argv[2];
5
+
6
+ switch (command) {
7
+ case 'collect':
8
+ require('./collect.js')();
9
+ break;
10
+ default:
11
+ console.log(
12
+ 'tracelet-next <command>\n\nCommands:\n collect Collect Next.js route stats into .tracelet/stats.json'
13
+ );
14
+ process.exit(command ? 1 : 0);
15
+ }
package/collect.js CHANGED
File without changes
package/index.js CHANGED
@@ -7,20 +7,21 @@
7
7
  *
8
8
  * Usage:
9
9
  * 1. Add to package.json scripts:
10
- * "postbuild": "node node_modules/tracelet-next/collect.js"
10
+ * "postbuild": "tracelet-next collect"
11
11
  *
12
12
  * 2. Or call manually after build:
13
- * node node_modules/tracelet-next/collect.js
13
+ * npx tracelet-next collect
14
+ *
15
+ * 3. Or programmatically:
16
+ * require('@traceletdev/next')()
14
17
  *
15
18
  * The script reads Next.js build manifests and generates .tracelet/stats.json
16
19
  */
17
20
 
18
- // Export the collect function for programmatic use
19
- module.exports = function collect() {
20
- require('./collect.js');
21
- };
21
+ // Export the collect function for programmatic use.
22
+ module.exports = require('./collect.js');
22
23
 
23
- // Main entry point (can be called directly)
24
+ // Main entry point (can be called directly, e.g. `node index.js`)
24
25
  if (require.main === module) {
25
26
  module.exports();
26
27
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@traceletdev/next",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Tracelet plugin for Next.js - automatically collects route statistics after builds",
5
5
  "type": "commonjs",
6
6
  "main": "index.js",
7
- "scripts": {
8
- "postinstall": "node collect.js"
7
+ "bin": {
8
+ "tracelet-next": "./cli.js"
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public"
@@ -24,11 +24,12 @@
24
24
  "license": "MIT",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/traceletdev/tracelet.git",
27
+ "url": "git+https://github.com/traceletdev/tracelet.git",
28
28
  "directory": "packages/tracelet-next"
29
29
  },
30
30
  "files": [
31
31
  "index.js",
32
+ "cli.js",
32
33
  "collect.js",
33
34
  "README.md"
34
35
  ]