@potstackhub/poka 2.0.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 +54 -0
- package/npm/cli.js +53 -0
- package/npm/index.js +39 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @potstackhub/poka
|
|
2
|
+
|
|
3
|
+
Tools for potstack software develop.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @potstackhub/poka
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
poka hello
|
|
15
|
+
poka version
|
|
16
|
+
poka help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## How it works
|
|
20
|
+
|
|
21
|
+
This package automatically installs the correct platform-specific binary:
|
|
22
|
+
|
|
23
|
+
- `@potstackhub/poka-linux-x64` - Linux x64
|
|
24
|
+
- `@potstackhub/poka-linux-arm64` - Linux ARM64
|
|
25
|
+
- `@potstackhub/poka-darwin-x64` - macOS x64 (Intel)
|
|
26
|
+
- `@potstackhub/poka-darwin-arm64` - macOS ARM64 (Apple Silicon)
|
|
27
|
+
- `@potstackhub/poka-win32-x64` - Windows x64
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Build the Rust binary
|
|
33
|
+
cargo build --release
|
|
34
|
+
|
|
35
|
+
# Run locally
|
|
36
|
+
./target/release/poka hello
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Publishing
|
|
40
|
+
|
|
41
|
+
Use the `publish.sh` script in the root directory:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
./publish.sh
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This will let you choose:
|
|
48
|
+
1. Publish platform binary package only
|
|
49
|
+
2. Publish main package only
|
|
50
|
+
3. Publish both (recommended)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
package/npm/cli.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
// Platform detection
|
|
7
|
+
const platform = process.platform;
|
|
8
|
+
const arch = process.arch;
|
|
9
|
+
|
|
10
|
+
// Map to package naming convention
|
|
11
|
+
const platformMap = {
|
|
12
|
+
'linux': 'linux',
|
|
13
|
+
'darwin': 'darwin',
|
|
14
|
+
'win32': 'win32'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const archMap = {
|
|
18
|
+
'x64': 'x64',
|
|
19
|
+
'arm64': 'arm64',
|
|
20
|
+
'arm': 'arm64'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const targetPlatform = platformMap[platform] || platform;
|
|
24
|
+
const targetArch = archMap[arch] || 'x64';
|
|
25
|
+
|
|
26
|
+
// Platform package name: @potstackhub/poka-linux-x64
|
|
27
|
+
const platformPackage = `@potstackhub/poka-${targetPlatform}-${targetArch}`;
|
|
28
|
+
|
|
29
|
+
// Try to find the binary in the platform package
|
|
30
|
+
let binaryPath;
|
|
31
|
+
try {
|
|
32
|
+
// Check if platform package is installed
|
|
33
|
+
const packagePath = path.join(__dirname, '../../node_modules', platformPackage, 'npm');
|
|
34
|
+
const binaryName = platform === 'win32' ? 'poka.exe' : 'poka';
|
|
35
|
+
binaryPath = path.join(packagePath, binaryName);
|
|
36
|
+
|
|
37
|
+
if (!fs.existsSync(binaryPath)) {
|
|
38
|
+
throw new Error(`Binary not found at ${binaryPath}`);
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error(`Error: Platform package not found for ${targetPlatform}-${targetArch}`);
|
|
42
|
+
console.error(`Expected package: ${platformPackage}`);
|
|
43
|
+
console.error('');
|
|
44
|
+
console.error('Please report this issue at: https://github.com/potstackhub/poka/issues');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Run the binary
|
|
49
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
50
|
+
stdio: 'inherit'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
process.exit(result.status ?? 1);
|
package/npm/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// JavaScript utilities (open source)
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Format a message with timestamp
|
|
5
|
+
* @param {string} message - The message to format
|
|
6
|
+
* @returns {string} Formatted message with timestamp
|
|
7
|
+
*/
|
|
8
|
+
function formatMessage(message) {
|
|
9
|
+
const timestamp = new Date().toISOString();
|
|
10
|
+
return `[${timestamp}] ${message}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parse command line arguments
|
|
15
|
+
* @param {string[]} args - Process arguments
|
|
16
|
+
* @returns {object} Parsed arguments object
|
|
17
|
+
*/
|
|
18
|
+
function parseArgs(args) {
|
|
19
|
+
const parsed = {
|
|
20
|
+
options: {},
|
|
21
|
+
commands: []
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
for (const arg of args) {
|
|
25
|
+
if (arg.startsWith('--')) {
|
|
26
|
+
const [key, value] = arg.slice(2).split('=');
|
|
27
|
+
parsed.options[key] = value || true;
|
|
28
|
+
} else {
|
|
29
|
+
parsed.commands.push(arg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return parsed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
formatMessage,
|
|
38
|
+
parseArgs
|
|
39
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@potstackhub/poka",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Tools for potstack software develop",
|
|
5
|
+
"main": "npm/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"poka": "npm/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"optionalDependencies": {
|
|
10
|
+
"@potstackhub/poka-linux-x64": "1.0.0",
|
|
11
|
+
"@potstackhub/poka-linux-arm64": "1.0.0",
|
|
12
|
+
"@potstackhub/poka-darwin-x64": "1.0.0",
|
|
13
|
+
"@potstackhub/poka-darwin-arm64": "1.0.0",
|
|
14
|
+
"@potstackhub/poka-win32-x64": "1.0.0"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"potstack",
|
|
18
|
+
"tools",
|
|
19
|
+
"cli"
|
|
20
|
+
],
|
|
21
|
+
"author": "potstack.top",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"files": [
|
|
24
|
+
"npm/**/*.js",
|
|
25
|
+
"lib/**/*",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">= 16"
|
|
30
|
+
}
|
|
31
|
+
}
|