@9apes/cli 0.1.0
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 +145 -0
- package/dist/command.d.ts +8 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +90 -0
- package/dist/command.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +37 -0
- package/dist/config.js.map +1 -0
- package/dist/index-dev.d.ts +3 -0
- package/dist/index-dev.d.ts.map +1 -0
- package/dist/index-dev.js +13 -0
- package/dist/index-dev.js.map +1 -0
- package/dist/index-local.d.ts +3 -0
- package/dist/index-local.d.ts.map +1 -0
- package/dist/index-local.js +13 -0
- package/dist/index-local.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/inject.d.ts +14 -0
- package/dist/inject.d.ts.map +1 -0
- package/dist/inject.js +161 -0
- package/dist/inject.js.map +1 -0
- package/dist/sourcemap.d.ts +48 -0
- package/dist/sourcemap.d.ts.map +1 -0
- package/dist/sourcemap.js +262 -0
- package/dist/sourcemap.js.map +1 -0
- package/dist/status.d.ts +17 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +72 -0
- package/dist/status.js.map +1 -0
- package/dist/upload.d.ts +25 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +119 -0
- package/dist/upload.js.map +1 -0
- package/dist/vite-plugin.d.ts +22 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +95 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +61 -0
- package/src/command.ts +100 -0
- package/src/config.ts +44 -0
- package/src/index-dev.ts +16 -0
- package/src/index-local.ts +16 -0
- package/src/index.ts +12 -0
- package/src/inject.ts +195 -0
- package/src/sourcemap.ts +317 -0
- package/src/status.ts +94 -0
- package/src/upload.ts +190 -0
- package/src/vite-plugin.ts +160 -0
- package/tsconfig.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# @9apes/cli
|
|
2
|
+
|
|
3
|
+
**Sourcemap tooling by [9Apes](https://9apes.com)**
|
|
4
|
+
|
|
5
|
+
> Inject debug IDs into your JavaScript bundles and upload source maps to the 9Apes platform -- as a CLI or a Vite plugin.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
`@9apes/cli` connects your production builds to the 9Apes error tracking pipeline. It generates unique debug IDs, injects them into compiled JavaScript files and their source maps, then uploads everything to your 9Apes project so stack traces can be un-minified in the dashboard.
|
|
12
|
+
|
|
13
|
+
**A valid 9Apes API key is required.** Get yours at [9apes.com](https://9apes.com).
|
|
14
|
+
|
|
15
|
+
### Two ways to use it
|
|
16
|
+
|
|
17
|
+
| Method | Best for |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| **Vite plugin** (`@9apes/cli/vite`) | Vite-based apps -- runs automatically at the end of `vite build` |
|
|
20
|
+
| **CLI** (`apesdev-cli` / `apeslocal-cli`) | Any build tool -- run as a post-build step |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm add -D @9apes/cli
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Vite Plugin
|
|
33
|
+
|
|
34
|
+
Add `withNineapesSourcemaps` to your Vite config and remove any manual post-build CLI step -- the plugin handles injection and upload automatically when `vite build` finishes.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// vite.config.ts
|
|
38
|
+
import { defineConfig } from 'vite';
|
|
39
|
+
import vue from '@vitejs/plugin-vue';
|
|
40
|
+
import { withNineapesSourcemaps } from '@9apes/cli/vite';
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
plugins: [
|
|
44
|
+
vue(),
|
|
45
|
+
withNineapesSourcemaps({
|
|
46
|
+
projectId: 'my-project',
|
|
47
|
+
apiKey: 'YOUR_API_KEY',
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
build: {
|
|
51
|
+
sourcemap: true,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Options
|
|
57
|
+
|
|
58
|
+
| Option | Type | Required | Description |
|
|
59
|
+
| --- | --- | --- | --- |
|
|
60
|
+
| `projectId` | `string` | Yes | Project identifier in your 9Apes dashboard |
|
|
61
|
+
| `apiKey` | `string` | Yes | 9Apes API key |
|
|
62
|
+
| `baseUrl` | `string` | No | API base URL (defaults to `https://dev.nineapes.com/api/v1`) |
|
|
63
|
+
| `releaseVersion` | `string` | No | Tag uploads with a release version |
|
|
64
|
+
|
|
65
|
+
> Make sure `build.sourcemap` is `true` in your Vite config -- the plugin needs `.js.map` files to work.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## CLI Usage
|
|
70
|
+
|
|
71
|
+
Two binaries are provided for different environments:
|
|
72
|
+
|
|
73
|
+
| Binary | API endpoint | Config file |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| `apesdev-cli` | `https://dev.nineapes.com/api/v1` | `config-dev.json` |
|
|
76
|
+
| `apeslocal-cli` | `http://127.0.0.1:8000/api/v1` | `config-local.json` |
|
|
77
|
+
|
|
78
|
+
Both CLIs share the same command structure.
|
|
79
|
+
|
|
80
|
+
### `config set [apikey]`
|
|
81
|
+
|
|
82
|
+
Save an API key for subsequent commands.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
apesdev-cli config set # interactive prompt
|
|
86
|
+
apesdev-cli config set YOUR_KEY # inline
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `config show`
|
|
90
|
+
|
|
91
|
+
Display the currently saved API key.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
apesdev-cli config show
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `sourcemaps inject <path>`
|
|
98
|
+
|
|
99
|
+
Inject debug IDs and upload source maps from a build output directory.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
apesdev-cli sourcemaps inject ./dist --projectid my-project
|
|
103
|
+
apesdev-cli sourcemaps inject ./dist --projectid my-project --release-version 1.2.0
|
|
104
|
+
apesdev-cli sourcemaps inject ./dist --projectid my-project --apikey YOUR_KEY
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Argument / Option | Required | Description |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `<path>` | Yes | Directory containing `.js` and `.js.map` files |
|
|
110
|
+
| `--projectid <id>` | Yes | Project identifier |
|
|
111
|
+
| `--release-version <version>` | No | Release version tag |
|
|
112
|
+
| `--apikey <key>` | No | API key (overrides saved config) |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## How It Works
|
|
117
|
+
|
|
118
|
+
1. Scans the output directory for `.js` and `.js.map` file pairs
|
|
119
|
+
2. Generates a unique UUID (debug ID) per file pair
|
|
120
|
+
3. Injects a small runtime snippet into each `.js` file that maps stack traces to its debug ID
|
|
121
|
+
4. Adds a `debug_id` field to each `.js.map` file
|
|
122
|
+
5. Uploads both files to 9Apes with project ID, release version, and git commit hash
|
|
123
|
+
6. The 9Apes dashboard uses these debug IDs to match production errors to their original source maps
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
This software is proprietary and provided under a commercial license by **9Apes Technologies**.
|
|
130
|
+
Unauthorized copying, modification, distribution, or use of this software outside the terms
|
|
131
|
+
of your subscription agreement is strictly prohibited.
|
|
132
|
+
|
|
133
|
+
Refer to your service agreement or contact [support@9apes.com](mailto:support@9apes.com) for licensing details.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Support
|
|
138
|
+
|
|
139
|
+
| Channel | Details |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| Documentation | [docs.9apes.com](https://docs.9apes.com) |
|
|
142
|
+
| Email | [support@9apes.com](mailto:support@9apes.com) |
|
|
143
|
+
| Dashboard | [app.9apes.com](https://dash.9apes.com) |
|
|
144
|
+
|
|
145
|
+
For enterprise support plans and SLAs, contact your account manager.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup commands for the CLI program
|
|
3
|
+
* @param configFileName - Name of the config file (e.g., 'config-local.json' or 'config-dev.json')
|
|
4
|
+
* @param baseUrl - Base URL for the API (e.g., 'http://127.0.0.1:8000/api/v1' or 'https://dev.nineapes.com/api/v1')
|
|
5
|
+
* @param cliName - Name of the CLI for error messages (e.g., 'apeslocal-cli' or 'apesdev-cli')
|
|
6
|
+
*/
|
|
7
|
+
export declare function setupCommands(configFileName: string, baseUrl: string, cliName: string): void;
|
|
8
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAuFrF"}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import { input } from '@inquirer/prompts';
|
|
3
|
+
import { loadConfig, saveConfig } from './config.js';
|
|
4
|
+
import { injectDebugIdsAndUpload } from './sourcemap.js';
|
|
5
|
+
/**
|
|
6
|
+
* Setup commands for the CLI program
|
|
7
|
+
* @param configFileName - Name of the config file (e.g., 'config-local.json' or 'config-dev.json')
|
|
8
|
+
* @param baseUrl - Base URL for the API (e.g., 'http://127.0.0.1:8000/api/v1' or 'https://dev.nineapes.com/api/v1')
|
|
9
|
+
* @param cliName - Name of the CLI for error messages (e.g., 'apeslocal-cli' or 'apesdev-cli')
|
|
10
|
+
*/
|
|
11
|
+
export function setupCommands(configFileName, baseUrl, cliName) {
|
|
12
|
+
// Config command with subcommands
|
|
13
|
+
const configCommand = program
|
|
14
|
+
.command('config')
|
|
15
|
+
.description('Manage configuration');
|
|
16
|
+
// Config set subcommand
|
|
17
|
+
configCommand
|
|
18
|
+
.command('set')
|
|
19
|
+
.description('Set API key')
|
|
20
|
+
.argument('[apikey]', 'API key (optional, will prompt if not provided)')
|
|
21
|
+
.action(async (apikey) => {
|
|
22
|
+
try {
|
|
23
|
+
let finalApiKey = apikey;
|
|
24
|
+
if (!finalApiKey) {
|
|
25
|
+
finalApiKey = await input({
|
|
26
|
+
message: 'Enter your API key:',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const configPath = saveConfig({ apiKey: finalApiKey }, configFileName);
|
|
30
|
+
console.log('✅ API key saved successfully at : ' + configPath);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error('❌ Error setting API key:', error);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// Config show subcommand
|
|
38
|
+
configCommand
|
|
39
|
+
.command('show')
|
|
40
|
+
.description('Show current API key')
|
|
41
|
+
.action(() => {
|
|
42
|
+
try {
|
|
43
|
+
const config = loadConfig(configFileName);
|
|
44
|
+
if (!config) {
|
|
45
|
+
console.log(`❌ No configuration found. Run "${cliName} config set" to set your API key.`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
console.log('Current API key:', config.apiKey);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('❌ Error reading config:', error);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Sourcemaps command with subcommands
|
|
56
|
+
const sourcemapsCommand = program
|
|
57
|
+
.command('sourcemaps')
|
|
58
|
+
.description('Manage source maps');
|
|
59
|
+
// Sourcemaps inject subcommand
|
|
60
|
+
sourcemapsCommand
|
|
61
|
+
.command('inject')
|
|
62
|
+
.description('Inject debug IDs into JavaScript files and source maps')
|
|
63
|
+
.argument('<path>', 'Directory path to process')
|
|
64
|
+
.requiredOption('--projectid <id>', 'Project ID (required)')
|
|
65
|
+
.option('--release-version <version>', 'Release version (optional)')
|
|
66
|
+
.option('--apikey <apikey>', 'Api key (optional, if config not set)')
|
|
67
|
+
.action(async (path, options) => {
|
|
68
|
+
try {
|
|
69
|
+
// Load configuration
|
|
70
|
+
const config = loadConfig(configFileName);
|
|
71
|
+
const apiKey = options.apikey || config?.apiKey;
|
|
72
|
+
if (!apiKey) {
|
|
73
|
+
console.log(`❌ No API key found. Run "${cliName} config set" to set your API key or use --apikey <apikey> to set the API key.`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
// Validate path parameter
|
|
77
|
+
if (!path) {
|
|
78
|
+
console.log('❌ Path argument is required.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
// Inject debug IDs into JavaScript files and source maps
|
|
82
|
+
await injectDebugIdsAndUpload(path, { apiKey }, options.projectid, baseUrl, options.releaseVersion);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('❌ Error processing sourcemaps:', error);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;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zD,MAAM,uBAAuB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QAEtG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function getConfigPath(configFileName: string): string;
|
|
5
|
+
export declare function loadConfig(configFileName: string): Config | null;
|
|
6
|
+
export declare function saveConfig(config: Config, configFileName: string): string;
|
|
7
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAahE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAiBzE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export function getConfigPath(configFileName) {
|
|
4
|
+
return path.join(process.cwd(), configFileName);
|
|
5
|
+
}
|
|
6
|
+
export function loadConfig(configFileName) {
|
|
7
|
+
try {
|
|
8
|
+
const configPath = getConfigPath(configFileName);
|
|
9
|
+
if (!fs.existsSync(configPath)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const configData = fs.readFileSync(configPath, 'utf8');
|
|
13
|
+
return JSON.parse(configData);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error('Error loading config:', error);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function saveConfig(config, configFileName) {
|
|
21
|
+
try {
|
|
22
|
+
const configPath = getConfigPath(configFileName);
|
|
23
|
+
const configDir = path.dirname(configPath);
|
|
24
|
+
// Create directory if it doesn't exist
|
|
25
|
+
if (!fs.existsSync(configDir)) {
|
|
26
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
// Write config file
|
|
29
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
30
|
+
return configPath;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error('Error saving config:', error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAM7B,MAAM,UAAU,aAAa,CAAC,cAAsB;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,cAAsB;IAC/C,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAW,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,cAAsB;IAC/D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3C,uCAAuC;QACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,oBAAoB;QACpB,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;QAC7C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-dev.d.ts","sourceRoot":"","sources":["../src/index-dev.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import { setupCommands } from './command.js';
|
|
4
|
+
// CLI version and description
|
|
5
|
+
program
|
|
6
|
+
.name('apesdev-cli')
|
|
7
|
+
.description('A CLI tool for dev environment')
|
|
8
|
+
.version('1.0.0');
|
|
9
|
+
// Setup commands with dev mode
|
|
10
|
+
setupCommands('config-dev.json', 'https://dev.nineapes.com/api/v1', 'apesdev-cli');
|
|
11
|
+
// Parse command line arguments
|
|
12
|
+
program.parse();
|
|
13
|
+
//# sourceMappingURL=index-dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-dev.js","sourceRoot":"","sources":["../src/index-dev.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,8BAA8B;AAC9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,+BAA+B;AAC/B,aAAa,CAAC,iBAAiB,EAAE,iCAAiC,EAAE,aAAa,CAAC,CAAC;AAEnF,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-local.d.ts","sourceRoot":"","sources":["../src/index-local.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import { setupCommands } from './command.js';
|
|
4
|
+
// CLI version and description
|
|
5
|
+
program
|
|
6
|
+
.name('apeslocal-cli')
|
|
7
|
+
.description('A CLI tool for local development environment')
|
|
8
|
+
.version('1.0.0');
|
|
9
|
+
// Setup commands with local mode
|
|
10
|
+
setupCommands('config-local.json', 'http://127.0.0.1:8000/api/v1', 'apeslocal-cli');
|
|
11
|
+
// Parse command line arguments
|
|
12
|
+
program.parse();
|
|
13
|
+
//# sourceMappingURL=index-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-local.js","sourceRoot":"","sources":["../src/index-local.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,8BAA8B;AAC9B,OAAO;KACJ,IAAI,CAAC,eAAe,CAAC;KACrB,WAAW,CAAC,8CAA8C,CAAC;KAC3D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,iCAAiC;AACjC,aAAa,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,eAAe,CAAC,CAAC;AAEpF,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import './command.js';
|
|
4
|
+
// CLI version and description
|
|
5
|
+
program
|
|
6
|
+
.name('apes-cli')
|
|
7
|
+
.description('A CLI tool built with TypeScript')
|
|
8
|
+
.version('1.0.0');
|
|
9
|
+
// Parse command line arguments
|
|
10
|
+
program.parse();
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,cAAc,CAAC;AAEtB,8BAA8B;AAC9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,kCAAkC,CAAC;KAC/C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/inject.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inject debug ID into JavaScript file
|
|
3
|
+
* @param jsFile - Path to JavaScript file
|
|
4
|
+
* @param debugIdSnippet - Debug ID snippet to inject
|
|
5
|
+
* @param debugId - Debug ID
|
|
6
|
+
*/
|
|
7
|
+
export declare function injectDebugIdIntoFile(jsFile: string, debugIdSnippet: string, debugId: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Inject debug ID into source map file
|
|
10
|
+
* @param mapFile - Path to source map file
|
|
11
|
+
* @param debugId - Debug ID to inject
|
|
12
|
+
*/
|
|
13
|
+
export declare function injectDebugIdIntoMapFile(mapFile: string | null, debugId: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAkHA;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAID;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CA+Bf"}
|
package/dist/inject.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
/**
|
|
3
|
+
* Read file as buffer and decode to UTF-8 with automatic BOM stripping
|
|
4
|
+
* @param jsFile - Path to JavaScript file
|
|
5
|
+
* @returns File content as UTF-8 string
|
|
6
|
+
*/
|
|
7
|
+
async function readFileAsUtf8(jsFile) {
|
|
8
|
+
const buffer = await fs.readFile(jsFile);
|
|
9
|
+
const decoder = new TextDecoder('utf-8');
|
|
10
|
+
return decoder.decode(buffer);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Find existing debug ID snippet in file content
|
|
14
|
+
* @param content - File content to search
|
|
15
|
+
* @returns Object with debug ID and its index if found, null otherwise
|
|
16
|
+
*/
|
|
17
|
+
function findExistingDebugId(content) {
|
|
18
|
+
const debugIdPattern = /_apesDebugIdIdentifier="apes-dbid-([^"]+)"/;
|
|
19
|
+
const match = content.match(debugIdPattern);
|
|
20
|
+
if (!match || match.index === undefined) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
id: match[1],
|
|
25
|
+
index: match.index,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Find the start position of the debug ID snippet
|
|
30
|
+
* @param content - File content to search
|
|
31
|
+
* @param debugIdIndex - Index where the debug ID identifier is found
|
|
32
|
+
* @returns Start index of the snippet, or -1 if not found
|
|
33
|
+
*/
|
|
34
|
+
function findSnippetStart(content, debugIdIndex) {
|
|
35
|
+
const snippetStartMarker = ';{try{';
|
|
36
|
+
for (let i = debugIdIndex; i >= 0; i--) {
|
|
37
|
+
if (content.slice(i, i + snippetStartMarker.length) === snippetStartMarker) {
|
|
38
|
+
return i;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find the end position of the debug ID snippet
|
|
45
|
+
* @param content - File content to search
|
|
46
|
+
* @param debugIdIndex - Index where the debug ID identifier is found
|
|
47
|
+
* @returns End index (exclusive) of the snippet, or -1 if not found
|
|
48
|
+
*/
|
|
49
|
+
function findSnippetEnd(content, debugIdIndex) {
|
|
50
|
+
const snippetEndMarker = '};';
|
|
51
|
+
for (let i = debugIdIndex; i < content.length; i++) {
|
|
52
|
+
if (content.slice(i, i + snippetEndMarker.length) === snippetEndMarker && i > debugIdIndex) {
|
|
53
|
+
return i + snippetEndMarker.length;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return -1;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Remove existing debug ID snippet from file content
|
|
60
|
+
* @param content - File content
|
|
61
|
+
* @param existingDebugId - Object containing the existing debug ID and its index
|
|
62
|
+
* @returns Content with the snippet removed
|
|
63
|
+
*/
|
|
64
|
+
function removeExistingSnippet(content, existingDebugId) {
|
|
65
|
+
const snippetStart = findSnippetStart(content, existingDebugId.index);
|
|
66
|
+
const snippetEnd = findSnippetEnd(content, existingDebugId.index);
|
|
67
|
+
if (snippetStart >= 0 && snippetEnd > snippetStart) {
|
|
68
|
+
return content.slice(0, snippetStart) + content.slice(snippetEnd);
|
|
69
|
+
}
|
|
70
|
+
return content;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Calculate the insertion position for the debug ID snippet
|
|
74
|
+
* Inserts after shebang (if present) and/or "use strict" directive (if present)
|
|
75
|
+
* @param content - File content
|
|
76
|
+
* @returns Index where the snippet should be inserted
|
|
77
|
+
*/
|
|
78
|
+
function calculateInsertionPosition(content) {
|
|
79
|
+
let position = 0;
|
|
80
|
+
let insertPosition = 0;
|
|
81
|
+
// Check for shebang (must be at start, ends at first newline)
|
|
82
|
+
const shebangMatch = content.match(/^#!.*(\r?\n)?/);
|
|
83
|
+
if (shebangMatch) {
|
|
84
|
+
position += shebangMatch[0].length;
|
|
85
|
+
insertPosition = position;
|
|
86
|
+
}
|
|
87
|
+
// Check for "use strict" after shebang
|
|
88
|
+
// Pattern: optional whitespace, then "use strict" with quotes, optional semicolon, optional whitespace
|
|
89
|
+
const useStrictPattern = /^\s*["']use strict["'];?\s*/;
|
|
90
|
+
const remainingContent = content.slice(position);
|
|
91
|
+
const useStrictMatch = remainingContent.match(useStrictPattern);
|
|
92
|
+
if (useStrictMatch) {
|
|
93
|
+
insertPosition = position + useStrictMatch[0].length;
|
|
94
|
+
}
|
|
95
|
+
return insertPosition;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Inject debug ID into JavaScript file
|
|
99
|
+
* @param jsFile - Path to JavaScript file
|
|
100
|
+
* @param debugIdSnippet - Debug ID snippet to inject
|
|
101
|
+
* @param debugId - Debug ID
|
|
102
|
+
*/
|
|
103
|
+
export async function injectDebugIdIntoFile(jsFile, debugIdSnippet, debugId) {
|
|
104
|
+
try {
|
|
105
|
+
let content = await readFileAsUtf8(jsFile);
|
|
106
|
+
const existingDebugId = findExistingDebugId(content);
|
|
107
|
+
// If existing debug ID matches the one to inject, skip injection
|
|
108
|
+
if (existingDebugId && existingDebugId.id === debugId) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// If different debug ID exists, remove the old snippet
|
|
112
|
+
if (existingDebugId) {
|
|
113
|
+
content = removeExistingSnippet(content, existingDebugId);
|
|
114
|
+
}
|
|
115
|
+
// Calculate insertion position and inject the new snippet
|
|
116
|
+
const insertPosition = calculateInsertionPosition(content);
|
|
117
|
+
const before = content.slice(0, insertPosition);
|
|
118
|
+
const after = content.slice(insertPosition);
|
|
119
|
+
const modifiedContent = before + debugIdSnippet + after;
|
|
120
|
+
// Write back to file
|
|
121
|
+
await fs.writeFile(jsFile, modifiedContent, 'utf-8');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
125
|
+
throw new Error(`Failed to inject debug ID into ${jsFile}: ${errorMessage}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Inject debug ID into source map file
|
|
130
|
+
* @param mapFile - Path to source map file
|
|
131
|
+
* @param debugId - Debug ID to inject
|
|
132
|
+
*/
|
|
133
|
+
export async function injectDebugIdIntoMapFile(mapFile, debugId) {
|
|
134
|
+
try {
|
|
135
|
+
if (!mapFile) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const content = await fs.readFile(mapFile, 'utf-8');
|
|
139
|
+
let sourcemap;
|
|
140
|
+
try {
|
|
141
|
+
sourcemap = JSON.parse(content);
|
|
142
|
+
}
|
|
143
|
+
catch (parseError) {
|
|
144
|
+
throw new Error(`Invalid JSON in sourcemap file: ${parseError}`);
|
|
145
|
+
}
|
|
146
|
+
// Skip if already has the same debug_id
|
|
147
|
+
if (sourcemap.debug_id === debugId) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// Add the debug_id field
|
|
151
|
+
sourcemap.debug_id = debugId;
|
|
152
|
+
// Use compact JSON (no pretty-printing)
|
|
153
|
+
const modifiedContent = JSON.stringify(sourcemap);
|
|
154
|
+
await fs.writeFile(mapFile, modifiedContent, 'utf-8');
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
158
|
+
throw new Error(`Failed to inject debug ID into ${mapFile}: ${errorMessage}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAGpC;;;;GAIG;AACH,KAAK,UAAU,cAAc,CAAC,MAAc;IAC1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAGD;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,OAAe;IAC1C,MAAM,cAAc,GAAG,4CAA4C,CAAC;IACpE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK,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C;QAED,yBAAyB;QACzB,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAC;QAE7B,wCAAwC;QACxC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAExD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,KAAK,YAAY,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a pair of JavaScript file and its corresponding source map file
|
|
4
|
+
*/
|
|
5
|
+
export interface FilePair {
|
|
6
|
+
jsFile: string;
|
|
7
|
+
mapFile: string | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate and resolve a directory path
|
|
11
|
+
* @param dirPath - Directory path to validate
|
|
12
|
+
* @returns Resolved absolute path
|
|
13
|
+
* @throws Error if path doesn't exist, isn't a directory, or lacks permissions
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateDirectoryPath(dirPath: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Scan directory for JavaScript files and their corresponding source maps
|
|
18
|
+
* @param dirPath - Directory path to scan
|
|
19
|
+
* @returns Tuple containing file pairs with both .js and .js.map files, and JS files without maps
|
|
20
|
+
*/
|
|
21
|
+
export declare function scanForJavaScriptFiles(dirPath: string): Promise<FilePair[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the current Git commit hash (HEAD)
|
|
24
|
+
* @param dirPath - Directory path to check for git repository
|
|
25
|
+
* @returns Git commit hash or undefined if not available
|
|
26
|
+
*/
|
|
27
|
+
export declare function getGitCommitHash(dirPath: string): Promise<string | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Generate a unique debug ID using UUID v4
|
|
30
|
+
* @returns UUID string
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateDebugId(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the debug ID snippet for the given debug ID
|
|
35
|
+
* @param debugId - Debug ID to get the snippet for
|
|
36
|
+
* @returns Debug ID snippet
|
|
37
|
+
*/
|
|
38
|
+
export declare function getDebugIdSnippet(debugId: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Inject debug IDs into JavaScript files and their corresponding source maps
|
|
41
|
+
* @param dirPath - Directory path to process
|
|
42
|
+
* @param config - Configuration object containing API key
|
|
43
|
+
* @param projectId - Project ID (required)
|
|
44
|
+
* @param baseUrl - Base URL for the API
|
|
45
|
+
* @param releaseVersion - Release version (optional)
|
|
46
|
+
*/
|
|
47
|
+
export declare function injectDebugIdsAndUpload(dirPath: string, config: Config, projectId: string, baseUrl: string, releaseVersion?: string): Promise<void>;
|
|
48
|
+
//# sourceMappingURL=sourcemap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourcemap.d.ts","sourceRoot":"","sources":["../src/sourcemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B5E;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAwCjF;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAenF;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAID;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CA6Jf"}
|