@port-experimental/port-cli 0.1.1-test
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/LICENSE +23 -0
- package/README.md +62 -0
- package/binaries/port-darwin-amd64 +0 -0
- package/binaries/port-darwin-arm64 +0 -0
- package/binaries/port-linux-amd64 +0 -0
- package/binaries/port-linux-arm64 +0 -0
- package/binaries/port-windows-amd64.exe +0 -0
- package/binaries/port-windows-arm64.exe +0 -0
- package/install.js +71 -0
- package/package.json +50 -0
- package/src/index.js +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Port Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Port CLI (npm package)
|
|
2
|
+
|
|
3
|
+
This is the npm package distribution of Port CLI. For the full documentation, see the [main repository](https://github.com/port-experimental/port-cli).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Global installation
|
|
9
|
+
npm install -g @port-experimental/port-cli
|
|
10
|
+
|
|
11
|
+
# Or use with npx (no installation needed)
|
|
12
|
+
npx @port-experimental/port-cli --version
|
|
13
|
+
|
|
14
|
+
# Or install locally in your project
|
|
15
|
+
npm install @port-experimental/port-cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
After installation, use the `port` command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
port --version
|
|
24
|
+
port config --init
|
|
25
|
+
port export --output backup.tar.gz
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Verifying Installation
|
|
29
|
+
|
|
30
|
+
To verify that Port CLI is installed correctly:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Check if the command is available
|
|
34
|
+
which port
|
|
35
|
+
|
|
36
|
+
# Check the version
|
|
37
|
+
port --version
|
|
38
|
+
|
|
39
|
+
# Test with help command
|
|
40
|
+
port --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If installation was successful, you should see output from the `port` command. If you get a "command not found" error, make sure:
|
|
44
|
+
|
|
45
|
+
1. The npm global bin directory is in your PATH
|
|
46
|
+
2. You installed with `-g` flag for global installation
|
|
47
|
+
3. You've restarted your terminal after installation
|
|
48
|
+
|
|
49
|
+
To check where npm installs global packages:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm root -g
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Platform Support
|
|
56
|
+
|
|
57
|
+
This package includes binaries for:
|
|
58
|
+
- Linux (amd64, arm64)
|
|
59
|
+
- macOS (amd64, arm64)
|
|
60
|
+
- Windows (amd64, arm64)
|
|
61
|
+
|
|
62
|
+
The correct binary for your platform will be automatically selected during installation.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/install.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
const binariesDir = path.join(__dirname, 'binaries');
|
|
8
|
+
const platform = os.platform();
|
|
9
|
+
const arch = os.arch();
|
|
10
|
+
|
|
11
|
+
// Map Node.js platform/arch to Go binary naming
|
|
12
|
+
const platformMap = {
|
|
13
|
+
'darwin': 'darwin',
|
|
14
|
+
'linux': 'linux',
|
|
15
|
+
'win32': 'windows'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const archMap = {
|
|
19
|
+
'x64': 'amd64',
|
|
20
|
+
'arm64': 'arm64'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const goPlatform = platformMap[platform];
|
|
24
|
+
const goArch = archMap[arch];
|
|
25
|
+
|
|
26
|
+
if (!goPlatform || !goArch) {
|
|
27
|
+
console.error(`Error: Unsupported platform ${platform}/${arch}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Determine binary name
|
|
32
|
+
const isWindows = platform === 'win32';
|
|
33
|
+
const binaryName = isWindows ? 'port.exe' : 'port';
|
|
34
|
+
const sourceBinary = isWindows
|
|
35
|
+
? `port-${goPlatform}-${goArch}.exe`
|
|
36
|
+
: `port-${goPlatform}-${goArch}`;
|
|
37
|
+
const sourcePath = path.join(binariesDir, sourceBinary);
|
|
38
|
+
const targetPath = path.join(binariesDir, binaryName);
|
|
39
|
+
|
|
40
|
+
// Check if source binary exists
|
|
41
|
+
if (!fs.existsSync(sourcePath)) {
|
|
42
|
+
console.error(`Error: Binary not found for platform ${goPlatform}/${goArch}`);
|
|
43
|
+
console.error(`Expected: ${sourcePath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Copy the correct binary to the target location
|
|
48
|
+
try {
|
|
49
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
50
|
+
|
|
51
|
+
// Set executable permissions on Unix systems
|
|
52
|
+
if (!isWindows) {
|
|
53
|
+
fs.chmodSync(targetPath, 0o755);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Delete other platform binaries to reduce package size
|
|
57
|
+
const files = fs.readdirSync(binariesDir);
|
|
58
|
+
files.forEach(file => {
|
|
59
|
+
const filePath = path.join(binariesDir, file);
|
|
60
|
+
const stat = fs.statSync(filePath);
|
|
61
|
+
|
|
62
|
+
if (stat.isFile() && file !== binaryName && file.startsWith('port-')) {
|
|
63
|
+
fs.unlinkSync(filePath);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log(`✓ Installed Port CLI for ${goPlatform}/${goArch}`);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Error installing binary: ${error.message}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@port-experimental/port-cli",
|
|
3
|
+
"version": "0.1.1-test",
|
|
4
|
+
"description": "A modular command-line interface for Port that enables data import/export, organization migration, and API operations",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"port": "src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"port",
|
|
14
|
+
"cli",
|
|
15
|
+
"devops",
|
|
16
|
+
"api",
|
|
17
|
+
"export",
|
|
18
|
+
"import",
|
|
19
|
+
"migrate"
|
|
20
|
+
],
|
|
21
|
+
"author": "Port Labs",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/port-experimental/port-cli.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/port-experimental/port-cli/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/port-experimental/port-cli#readme",
|
|
31
|
+
"files": [
|
|
32
|
+
"src/",
|
|
33
|
+
"install.js",
|
|
34
|
+
"binaries/",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=12.0.0"
|
|
40
|
+
},
|
|
41
|
+
"os": [
|
|
42
|
+
"darwin",
|
|
43
|
+
"linux",
|
|
44
|
+
"win32"
|
|
45
|
+
],
|
|
46
|
+
"cpu": [
|
|
47
|
+
"x64",
|
|
48
|
+
"arm64"
|
|
49
|
+
]
|
|
50
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
const platform = os.platform();
|
|
8
|
+
const isWindows = platform === 'win32';
|
|
9
|
+
const binaryName = isWindows ? 'port.exe' : 'port';
|
|
10
|
+
const binaryPath = path.join(__dirname, '..', 'binaries', binaryName);
|
|
11
|
+
|
|
12
|
+
// Get all command-line arguments (skip node and script path)
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
|
|
15
|
+
// Spawn the Go binary with all arguments
|
|
16
|
+
const child = spawn(binaryPath, args, {
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
shell: false
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Forward exit code
|
|
22
|
+
child.on('exit', (code) => {
|
|
23
|
+
process.exit(code !== null ? code : 1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Handle errors
|
|
27
|
+
child.on('error', (error) => {
|
|
28
|
+
console.error(`Error executing Port CLI: ${error.message}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|