codexdb-sdk 0.1.5 → 0.1.14

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/PUBLISH.md CHANGED
@@ -1,21 +1,187 @@
1
1
  # Publishing to npm
2
2
 
3
- To publish the CodexDB Node.js SDK to npm:
3
+ ## Quick Start (Automated)
4
4
 
5
- 1. Make sure you have an npm account: https://www.npmjs.com/signup
6
- 2. Login to npm in your terminal:
7
- ```sh
5
+ ```bash
6
+ cd /Users/everton/workspace/codex/sdk/nodejs
7
+ npm run publish
8
+ ```
9
+
10
+ This runs a complete automated workflow with validation and confirmation.
11
+
12
+ ## Prerequisites
13
+
14
+ 1. **npm account**: https://www.npmjs.com/signup
15
+ 2. **Login locally**:
16
+ ```bash
8
17
  npm login
9
18
  ```
10
- 3. In the sdk/nodejs directory, publish the package:
11
- ```sh
12
- npm publish
19
+ 3. **Verify credentials**:
20
+ ```bash
21
+ npm whoami
13
22
  ```
14
23
 
15
- If you get a name conflict error, choose a unique package name in package.json (e.g., codexdb-sdk-everton) and try again.
24
+ ## Publishing Methods
25
+
26
+ ### Method 1: Automated Script (Recommended)
27
+
28
+ ```bash
29
+ npm run publish
30
+ ```
31
+
32
+ This script:
33
+ - ✓ Installs dependencies
34
+ - ✓ Runs tests
35
+ - ✓ Verifies codex-cli binary
36
+ - ✓ Validates npm credentials
37
+ - ✓ Performs dry-run
38
+ - ✓ Asks for confirmation
39
+ - ✓ Publishes to npm
40
+
41
+ ### Method 2: Pre-Publish Checklist
42
+
43
+ Validate everything before publishing:
44
+
45
+ ```bash
46
+ npm run publish-check
47
+ ```
48
+
49
+ Then publish manually:
50
+
51
+ ```bash
52
+ npm publish
53
+ ```
54
+
55
+ ### Method 3: Manual Steps
56
+
57
+ ```bash
58
+ # Install dependencies
59
+ npm install
60
+
61
+ # Run tests
62
+ npm test
63
+
64
+ # Publish
65
+ npm publish
66
+ ```
67
+
68
+ ## Version Management
69
+
70
+ ### Automated versioning
71
+
72
+ ```bash
73
+ # Patch (0.1.6 → 0.1.7)
74
+ npm version patch
75
+
76
+ # Minor (0.1.6 → 0.2.0)
77
+ npm version minor
78
+
79
+ # Major (0.1.6 → 1.0.0)
80
+ npm version major
81
+ ```
82
+
83
+ Then publish:
84
+ ```bash
85
+ npm publish
86
+ ```
87
+
88
+ ### Manual versioning
89
+
90
+ Edit `package.json` and update the `version` field, then publish:
91
+ ```bash
92
+ npm publish
93
+ ```
94
+
95
+ ## Troubleshooting
96
+
97
+ ### "Not authenticated"
98
+ ```bash
99
+ npm login
100
+ npm whoami # verify
101
+ ```
102
+
103
+ ### "Already published at this version"
104
+ ```bash
105
+ npm version patch
106
+ npm publish
107
+ ```
108
+
109
+ ### "Binary download fails"
110
+
111
+ The postinstall script downloads codex-cli from GitHub releases. Verify:
112
+ - Version in package.json matches a GitHub release tag
113
+ - GitHub release contains the binary files
114
+
115
+ ### "Tests fail"
116
+ ```bash
117
+ npm test # See detailed errors
118
+ ```
119
+
120
+ ## Verification After Publishing
121
+
122
+ ```bash
123
+ # Check latest version
124
+ npm view codexdb-sdk@latest
125
+
126
+ # Test installation
127
+ npm install codexdb-sdk@latest
128
+
129
+ # View on npm
130
+ open https://www.npmjs.com/package/codexdb-sdk
131
+ ```
132
+
133
+ ## Files Included in npm Package
134
+
135
+ Included (via package.json + files field or .npmignore):
136
+ - index.js
137
+ - package.json
138
+ - README.md
139
+ - LICENSE
140
+ - codex-cli (binary)
141
+ - node_modules/
142
+
143
+ Excluded:
144
+ - test.js
145
+ - example_app.js
146
+ - scripts/
147
+ - .npmignore
148
+ - IDE config
149
+ - OS files
150
+
151
+ ## Automated Publishing (CI/CD)
152
+
153
+ Example GitHub Actions workflow:
154
+
155
+ ```yaml
156
+ name: Publish to npm
157
+ on:
158
+ push:
159
+ tags:
160
+ - 'v*'
161
+
162
+ jobs:
163
+ publish:
164
+ runs-on: ubuntu-latest
165
+ steps:
166
+ - uses: actions/checkout@v2
167
+ - uses: actions/setup-node@v2
168
+ with:
169
+ node-version: '18'
170
+ registry-url: 'https://registry.npmjs.org'
171
+ - run: cd sdk/nodejs && npm install
172
+ - run: cd sdk/nodejs && npm test
173
+ - run: cd sdk/nodejs && npm publish
174
+ env:
175
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
176
+ ```
177
+
178
+ Setup:
179
+ 1. Create npm token: https://www.npmjs.com/settings/~/tokens
180
+ 2. Add to GitHub: Settings → Secrets → `NPM_TOKEN`
181
+
182
+ ## Additional Resources
16
183
 
17
- ## Versioning
18
- - Update the version field in package.json before publishing a new release.
184
+ - npm docs: https://docs.npmjs.com/cli/
185
+ - GitHub releases: https://github.com/evertonmj/codex/releases
186
+ - Main README: ../../README.md
19
187
 
20
- ## Automated Publishing (optional)
21
- You can automate npm publishing using GitHub Actions or another CI/CD tool. Let me know if you want a workflow example!
package/codex-cli ADDED
Binary file
File without changes
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "codexdb-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.14",
4
4
  "description": "Node.js SDK for CodexDB (wrapper around codex-cli)",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "node test.js",
8
- "postinstall": "node scripts/postinstall.js"
8
+ "postinstall": "node scripts/postinstall.js",
9
+ "publish-check": "node scripts/publish-check.js",
10
+ "release": "bash scripts/publish.sh"
11
+ },
12
+ "dependencies": {
13
+ "follow-redirects": "^1.16.0"
9
14
  },
10
15
  "keywords": [
11
16
  "codexdb",
package/example_app.js DELETED
@@ -1,26 +0,0 @@
1
- const path = require('path');
2
- const CodexClient = require('./index');
3
-
4
- const dbPath = path.resolve(__dirname, 'example-db.db');
5
- const client = new CodexClient({ file: dbPath });
6
-
7
- (async () => {
8
- // Set a value
9
- await client.set('greeting', { msg: 'Hello from Node.js!' });
10
-
11
- // Get the value
12
- const value = await client.get('greeting');
13
- console.log('Greeting:', value.msg);
14
-
15
- // List all keys
16
- const keys = await client.keys();
17
- console.log('All keys:', keys);
18
-
19
- // Delete the key
20
- const deleted = await client.delete('greeting');
21
- console.log('Deleted:', deleted);
22
-
23
- // Cleanup
24
- const fs = require('fs');
25
- try { fs.unlinkSync(dbPath); } catch (e) {}
26
- })();
@@ -1,42 +0,0 @@
1
- const https = require('https');
2
- const fs = require('fs');
3
- const os = require('os');
4
- const fs = require('fs');
5
- const os = require('os');
6
- const path = require('path');
7
- const { https } = require('follow-redirects');
8
-
9
- // Map OS/platform to binary URLs
10
- const BINARIES = {
11
- darwin: 'https://github.com/evertonmj/codex/releases/latest/download/codex-cli-macos',
12
- linux: 'https://github.com/evertonmj/codex/releases/latest/download/codex-cli-linux',
13
- win32: 'https://github.com/evertonmj/codex/releases/latest/download/codex-cli-win.exe'
14
- };
15
-
16
- const platform = os.platform();
17
- const url = BINARIES[platform];
18
- if (!url) {
19
- console.error(`No binary available for platform: ${platform}`);
20
- process.exit(1);
21
- }
22
-
23
- const dest = path.join(__dirname, '..', 'codex-cli' + (platform === 'win32' ? '.exe' : ''));
24
-
25
- console.log(`Downloading codex-cli for ${platform}...`);
26
-
27
- https.get(url, (res) => {
28
- if (res.statusCode !== 200) {
29
- console.error(`Failed to download binary: ${res.statusCode}`);
30
- process.exit(1);
31
- }
32
- const file = fs.createWriteStream(dest, { mode: 0o755 });
33
- res.pipe(file);
34
- file.on('finish', () => {
35
- file.close(() => {
36
- console.log('codex-cli downloaded to', dest);
37
- });
38
- });
39
- }).on('error', (err) => {
40
- console.error('Download error:', err);
41
- process.exit(1);
42
- });
package/test.js DELETED
@@ -1,34 +0,0 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
- const CodexClient = require('./index');
4
-
5
- (async () => {
6
- const dbPath = path.resolve(__dirname, 'test-db.db');
7
-
8
- // cleanup before test
9
- try { fs.unlinkSync(dbPath); } catch (e) {}
10
-
11
- const client = new CodexClient({ file: dbPath });
12
-
13
- await client.set('test-key', { hello: 'world' });
14
- const value = await client.get('test-key');
15
-
16
- if (value.hello !== 'world') throw new Error('value mismatch');
17
-
18
- const hasKey = await client.has('test-key');
19
- if (!hasKey) throw new Error('expected key to exist');
20
-
21
- const keys = await client.keys();
22
- if (!keys.includes('test-key')) throw new Error('expected keys to include test-key');
23
-
24
- await client.delete('test-key');
25
- const hasAfterDelete = await client.has('test-key');
26
- if (hasAfterDelete) throw new Error('expected key to be deleted');
27
-
28
- await client.clear();
29
-
30
- // cleanup after test
31
- try { fs.unlinkSync(dbPath); } catch (e) {}
32
-
33
- console.log('Node.js SDK smoke test passed');
34
- })();