@basictech/cli 0.0.22 → 0.0.24

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.
Files changed (112) hide show
  1. package/dist/commands/account.d.ts +2 -0
  2. package/dist/commands/account.d.ts.map +1 -0
  3. package/dist/commands/account.js +18 -0
  4. package/dist/commands/account.js.map +1 -0
  5. package/dist/commands/debug.d.ts +2 -0
  6. package/dist/commands/debug.d.ts.map +1 -0
  7. package/dist/commands/debug.js +6 -0
  8. package/dist/commands/debug.js.map +1 -0
  9. package/dist/commands/init.d.ts +10 -0
  10. package/dist/commands/init.d.ts.map +1 -0
  11. package/dist/commands/init.js +111 -0
  12. package/dist/commands/init.js.map +1 -0
  13. package/dist/commands/login.d.ts +2 -0
  14. package/dist/commands/login.d.ts.map +1 -0
  15. package/dist/commands/login.js +20 -0
  16. package/dist/commands/login.js.map +1 -0
  17. package/dist/commands/logout.d.ts +2 -0
  18. package/dist/commands/logout.d.ts.map +1 -0
  19. package/dist/commands/logout.js +7 -0
  20. package/dist/commands/logout.js.map +1 -0
  21. package/dist/commands/projects.d.ts +2 -0
  22. package/dist/commands/projects.d.ts.map +1 -0
  23. package/dist/commands/projects.js +90 -0
  24. package/dist/commands/projects.js.map +1 -0
  25. package/dist/commands/pull.d.ts +2 -0
  26. package/dist/commands/pull.d.ts.map +1 -0
  27. package/dist/commands/pull.js +366 -0
  28. package/dist/commands/pull.js.map +1 -0
  29. package/dist/commands/push.d.ts +2 -0
  30. package/dist/commands/push.d.ts.map +1 -0
  31. package/dist/commands/push.js +403 -0
  32. package/dist/commands/push.js.map +1 -0
  33. package/dist/commands/status.d.ts +2 -0
  34. package/dist/commands/status.d.ts.map +1 -0
  35. package/dist/commands/status.js +385 -0
  36. package/dist/commands/status.js.map +1 -0
  37. package/dist/commands/teams.d.ts +2 -0
  38. package/dist/commands/teams.d.ts.map +1 -0
  39. package/dist/commands/teams.js +164 -0
  40. package/dist/commands/teams.js.map +1 -0
  41. package/dist/commands/update.d.ts +2 -0
  42. package/dist/commands/update.d.ts.map +1 -0
  43. package/dist/commands/update.js +76 -0
  44. package/dist/commands/update.js.map +1 -0
  45. package/dist/commands/version.d.ts +2 -0
  46. package/dist/commands/version.d.ts.map +1 -0
  47. package/dist/commands/version.js +21 -0
  48. package/dist/commands/version.js.map +1 -0
  49. package/dist/components/Form.d.ts +15 -0
  50. package/dist/components/Form.d.ts.map +1 -0
  51. package/dist/components/Form.js +69 -0
  52. package/dist/components/Form.js.map +1 -0
  53. package/dist/components/InitForm.d.ts +17 -0
  54. package/dist/components/InitForm.d.ts.map +1 -0
  55. package/dist/components/InitForm.js +358 -0
  56. package/dist/components/InitForm.js.map +1 -0
  57. package/dist/components/Spinner.d.ts +7 -0
  58. package/dist/components/Spinner.d.ts.map +1 -0
  59. package/dist/components/Spinner.js +15 -0
  60. package/dist/components/Spinner.js.map +1 -0
  61. package/dist/components/Table.d.ts +24 -0
  62. package/dist/components/Table.d.ts.map +1 -0
  63. package/dist/components/Table.js +69 -0
  64. package/dist/components/Table.js.map +1 -0
  65. package/dist/components/TeamForm.d.ts +10 -0
  66. package/dist/components/TeamForm.d.ts.map +1 -0
  67. package/dist/components/TeamForm.js +193 -0
  68. package/dist/components/TeamForm.js.map +1 -0
  69. package/dist/index.d.ts +3 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +243 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/lib/api.d.ts +23 -0
  74. package/dist/lib/api.d.ts.map +1 -0
  75. package/dist/lib/api.js +133 -0
  76. package/dist/lib/api.js.map +1 -0
  77. package/dist/lib/auth.d.ts +17 -0
  78. package/dist/lib/auth.d.ts.map +1 -0
  79. package/dist/lib/auth.js +288 -0
  80. package/dist/lib/auth.js.map +1 -0
  81. package/dist/lib/config-templates.d.ts +9 -0
  82. package/dist/lib/config-templates.d.ts.map +1 -0
  83. package/dist/lib/config-templates.js +117 -0
  84. package/dist/lib/config-templates.js.map +1 -0
  85. package/dist/lib/constants.d.ts +18 -0
  86. package/dist/lib/constants.d.ts.map +1 -0
  87. package/dist/lib/constants.js +32 -0
  88. package/dist/lib/constants.js.map +1 -0
  89. package/dist/lib/errors.d.ts +21 -0
  90. package/dist/lib/errors.d.ts.map +1 -0
  91. package/dist/lib/errors.js +75 -0
  92. package/dist/lib/errors.js.map +1 -0
  93. package/dist/lib/platform.d.ts +11 -0
  94. package/dist/lib/platform.d.ts.map +1 -0
  95. package/dist/lib/platform.js +133 -0
  96. package/dist/lib/platform.js.map +1 -0
  97. package/dist/lib/schema.d.ts +24 -0
  98. package/dist/lib/schema.d.ts.map +1 -0
  99. package/dist/lib/schema.js +162 -0
  100. package/dist/lib/schema.js.map +1 -0
  101. package/dist/lib/types.d.ts +111 -0
  102. package/dist/lib/types.d.ts.map +1 -0
  103. package/dist/lib/types.js +2 -0
  104. package/dist/lib/types.js.map +1 -0
  105. package/dist/lib/version.d.ts +2 -0
  106. package/dist/lib/version.d.ts.map +1 -0
  107. package/dist/lib/version.js +22 -0
  108. package/dist/lib/version.js.map +1 -0
  109. package/package.json +63 -12
  110. package/readme.md +92 -35
  111. package/bin/readme.md +0 -61
  112. package/index.js +0 -108
package/package.json CHANGED
@@ -1,19 +1,70 @@
1
1
  {
2
2
  "name": "@basictech/cli",
3
- "version": "0.0.22",
4
- "description": "basictech cli for creating & managing your projects",
5
- "main": "index.js",
6
- "files": [
7
- "index.js"
8
- ],
3
+ "version": "0.0.24",
4
+ "type": "module",
5
+ "description": "Basic CLI for creating & managing your projects",
6
+ "main": "dist/index.js",
9
7
  "bin": {
10
- "basic": "./bin/basic-cli"
8
+ "basic": "dist/index.js"
11
9
  },
12
10
  "scripts": {
13
- "preinstall": "node ./index.js",
14
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "build": "tsc",
12
+ "dev": "tsx src/index.ts",
13
+ "dev:watch": "tsx watch src/index.ts",
14
+ "test": "vitest run --exclude='tests/components/**'",
15
+ "test:all": "vitest run",
16
+ "test:components": "vitest run tests/components",
17
+ "test:watch": "vitest watch --exclude='tests/components/**'",
18
+ "test:ui": "vitest --ui",
19
+ "test:coverage": "vitest --coverage",
20
+ "changeset": "changeset",
21
+ "changeset:version": "changeset version",
22
+ "changeset:publish": "changeset publish",
23
+ "changeset:status": "changeset status",
24
+ "prepublishOnly": "npm run build"
25
+ },
26
+ "dependencies": {
27
+ "commander": "^12.1.0",
28
+ "ink": "^5.0.1",
29
+ "react": "^18.3.1"
30
+ },
31
+ "devDependencies": {
32
+ "@changesets/cli": "^2.29.4",
33
+ "@types/node": "^22.9.0",
34
+ "@types/react": "^18.3.12",
35
+ "@vitest/coverage-v8": "^1.6.1",
36
+ "@vitest/ui": "^1.6.1",
37
+ "ink-testing-library": "^4.0.0",
38
+ "tsx": "^4.19.2",
39
+ "typescript": "^5.6.3",
40
+ "vitest": "^1.6.1"
41
+ },
42
+ "files": [
43
+ "dist/**/*.js",
44
+ "dist/**/*.d.ts",
45
+ "dist/**/*.js.map",
46
+ "dist/**/*.d.ts.map"
47
+ ],
48
+ "keywords": [
49
+ "cli",
50
+ "basic",
51
+ "database",
52
+ "development",
53
+ "schema",
54
+ "typescript",
55
+ "react-ink"
56
+ ],
57
+ "author": "Basic Team",
58
+ "license": "MIT",
59
+ "homepage": "https://basic.tech",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/basicdb/basic-cli.git"
63
+ },
64
+ "bugs": {
65
+ "url": "https://github.com/basicdb/basic-cli/issues"
15
66
  },
16
- "author": "raz@basic.tech",
17
- "license": "ISC",
18
- "dependencies": {}
67
+ "engines": {
68
+ "node": ">=18.0.0"
69
+ }
19
70
  }
package/readme.md CHANGED
@@ -1,61 +1,118 @@
1
1
  # Basic CLI
2
2
 
3
- A command-line interface for interacting with the Basic API.
3
+ A command-line interface for interacting with the Basic API, built with TypeScript and React Ink.
4
4
 
5
- ## Docs
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @basictech/cli
9
+ ```
6
10
 
7
- - https://docs.basic.tech/get-started/cli
11
+ ## Quick Start
8
12
 
13
+ ```bash
14
+ # Login to your Basic account
15
+ basic login
9
16
 
17
+ # Create a new project
18
+ basic init --new --name "My Project" --ts
10
19
 
11
- ## Installation
20
+ # Check project status
21
+ basic status
22
+
23
+ # Push schema changes
24
+ basic push
25
+
26
+ # Pull latest schema
27
+ basic pull
28
+ ```
29
+
30
+ ## Available Commands
31
+
32
+ ### Authentication
33
+ - `basic login` - Login to your Basic account
34
+ - `basic logout` - Logout from your Basic account
35
+ - `basic account` - Show account information
36
+
37
+ ### Project Management
38
+ - `basic init` - Create a new project or import existing project
39
+ - `basic projects` - List your projects
40
+ - `basic teams` - List teams or create new teams
41
+ - `basic status` - Show schema status in current project
42
+ - `basic push` - Push schema changes to remote
43
+ - `basic pull` - Pull schema from remote
44
+
45
+ ### Utility
46
+ - `basic version` - Show CLI version and check for updates
47
+ - `basic update` - Update CLI to the latest version
48
+ - `basic help` - Show help information
49
+ - `basic debug` - Show Basic config directory location
50
+
51
+ ## Init Command Options
52
+
53
+ The `basic init` command supports several options for automation:
12
54
 
13
55
  ```bash
14
- npm i -g @basictech/cli
56
+ # Interactive mode (default)
57
+ basic init
58
+
59
+ # Create new project (skip project type selection)
60
+ basic init --new --name "My Project" --ts
61
+
62
+ # Import existing project
63
+ basic init --existing --project "project-id"
64
+
65
+ # Use JavaScript config
66
+ basic init --new --name "My Project" --js
15
67
  ```
16
68
 
69
+ ## Authentication
17
70
 
18
- ## Usage
71
+ Before using commands that require authentication, make sure you're logged in:
19
72
 
20
- ## Available Commands
73
+ ```bash
74
+ basic login
75
+ ```
76
+
77
+ This will open your browser and guide you through the OAuth flow.
21
78
 
22
- 1. **account**
23
- - Description: Show account information
24
- - Usage: `basic account`
79
+ ## Project Workflow
25
80
 
26
- 2. **login**
27
- - Description: Log in to the Basic API
28
- - Usage: `basic login`
81
+ 1. **Initialize**: `basic init` to create or import a project
82
+ 2. **Develop**: Modify your `basic.config.ts/js` file
83
+ 3. **Check Status**: `basic status` to see changes
84
+ 4. **Push Changes**: `basic push` to publish your schema
85
+ 5. **Pull Updates**: `basic pull` to get latest remote changes
29
86
 
30
- 3. **logout**
31
- - Description: Log out of the Basic API
32
- - Usage: `basic logout`
87
+ ## Schema Management
33
88
 
34
- 4. **status**
35
- - Description: Show login statuss
36
- - Usage: `basic status`
89
+ The CLI automatically manages your schema versioning:
37
90
 
38
- 5. **projects**
39
- - Description: Show projects
40
- - Usage: `basic projects`
91
+ - **Push**: Increments version and uploads changes
92
+ - **Pull**: Downloads latest schema and updates local files
93
+ - **Status**: Shows version differences and conflicts
94
+ - **Init**: Automatically pulls latest schema when setting up projects
41
95
 
42
- 6. **init**
43
- - Description: Create a new project
44
- - Usage: `basic init`
96
+ ## Documentation
45
97
 
46
- 7. **help**
47
- - Description: Show help information
48
- - Usage: `basic help`
98
+ - [Basic Documentation](https://docs.basic.tech)
99
+ - [CLI Documentation](https://docs.basic.tech/get-started/cli)
49
100
 
50
- ## Examples
101
+ ## Contributing
51
102
 
103
+ This CLI is built with:
104
+ - **TypeScript** for type safety
105
+ - **React Ink** for interactive UI components
106
+ - **Commander.js** for CLI argument parsing
107
+ - **Vitest** for testing
52
108
 
53
- ## Notes
109
+ ## Support
54
110
 
55
- - Make sure you're logged in using the `login` command before using commands that require authentication.
56
- - Use the `help` command to see this list of available commands in the CLI.
111
+ If you encounter issues or have questions:
112
+ - Visit [Basic Documentation](https://docs.basic.tech)
113
+ - Check the [CLI Documentation](https://docs.basic.tech/get-started/cli)
114
+ - Use `basic help` for command-specific help
57
115
 
58
- Links:
116
+ ## License
59
117
 
60
- - https://www.npmjs.com/package/@basictech/cli
61
- https://docs.basic.tech/get-started/cli
118
+ MIT
package/bin/readme.md DELETED
@@ -1,61 +0,0 @@
1
- # Basic CLI
2
-
3
- A command-line interface for interacting with the Basic API.
4
-
5
- ## Docs
6
-
7
- - https://docs.basic.tech/get-started/cli
8
-
9
-
10
-
11
- ## Installation
12
-
13
- ```bash
14
- npm i -g @basictech/cli
15
- ```
16
-
17
-
18
- ## Usage
19
-
20
- ## Available Commands
21
-
22
- 1. **account**
23
- - Description: Show account information
24
- - Usage: `basic account`
25
-
26
- 2. **login**
27
- - Description: Log in to the Basic API
28
- - Usage: `basic login`
29
-
30
- 3. **logout**
31
- - Description: Log out of the Basic API
32
- - Usage: `basic logout`
33
-
34
- 4. **status**
35
- - Description: Show login statuss
36
- - Usage: `basic status`
37
-
38
- 5. **projects**
39
- - Description: Show projects
40
- - Usage: `basic projects`
41
-
42
- 6. **init**
43
- - Description: Create a new project
44
- - Usage: `basic init`
45
-
46
- 7. **help**
47
- - Description: Show help information
48
- - Usage: `basic help`
49
-
50
- ## Examples
51
-
52
-
53
- ## Notes
54
-
55
- - Make sure you're logged in using the `login` command before using commands that require authentication.
56
- - Use the `help` command to see this list of available commands in the CLI.
57
-
58
- Links:
59
-
60
- - https://www.npmjs.com/package/@basictech/cli
61
- https://docs.basic.tech/get-started/cli
package/index.js DELETED
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
- const path = require('path');
3
- const { execSync } = require('child_process');
4
- const os = require('os');
5
- const fs = require('fs');
6
- const https = require('https');
7
-
8
- const REPO_OWNER = 'basicdb';
9
- const REPO_NAME = 'basic-cli';
10
-
11
-
12
- const downloadBinary = async (url, dest) => {
13
- return new Promise((resolve, reject) => {
14
- const file = fs.createWriteStream(dest);
15
-
16
- const makeRequest = (url) => {
17
- https
18
- .get(url, (response) => {
19
- if (response.statusCode === 302 && response.headers.location) {
20
- console.log(`Redirecting to ${response.headers.location}`);
21
- makeRequest(response.headers.location);
22
- } else if (response.statusCode === 200) {
23
- response.pipe(file);
24
- file.on('finish', () => {
25
- file.close(() => resolve());
26
- });
27
- } else {
28
- reject(
29
- new Error(
30
- `Failed to download binary: ${response.statusCode} - ${response.statusMessage}`
31
- )
32
- );
33
- }
34
- })
35
- .on('error', (err) => {
36
- fs.unlink(dest, () => reject(err));
37
- });
38
- };
39
-
40
- makeRequest(url);
41
- });
42
- };
43
-
44
- const getPackageVersion = () => {
45
- const packageJsonPath = path.join(__dirname, 'package.json');
46
- if (!fs.existsSync(packageJsonPath)) {
47
- throw new Error('package.json not found');
48
- }
49
-
50
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
51
- return packageJson.version;
52
- };
53
-
54
- const installBinary = async () => {
55
- const archMap = {
56
- x64: 'x86_64',
57
- arm64: 'arm64',
58
- ia32: 'i386',
59
- };
60
-
61
- const platformMap = {
62
- win32: 'Windows',
63
- darwin: 'Darwin',
64
- linux: 'Linux',
65
- };
66
-
67
- const arch = archMap[os.arch()] || os.arch();
68
- const platform = platformMap[os.platform()] || os.platform();
69
- const version = getPackageVersion();
70
- if (!arch || !platform) {
71
- throw new Error(`Unsupported platform/architecture: ${os.platform()}/${os.arch()}`);
72
- }
73
-
74
- const extension = platform === 'Windows' ? 'zip' : 'tar.gz';
75
- const fileName = `basic-cli_${platform}_${arch}.${extension}`;
76
-
77
- const destPath = path.join(__dirname, 'bin', `basic-cli${platform === 'Windows' ? '.exe' : ''}`);
78
- const tempPath = path.join(__dirname, fileName);
79
- const downloadUrl = `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${version}/${fileName}`;
80
- console.log(`Downloading binary from ${downloadUrl}`);
81
- await downloadBinary(downloadUrl, tempPath);
82
-
83
- if (platform === 'Windows') {
84
- execSync(`tar -xf ${tempPath} -C ${path.dirname(destPath)}`);
85
- } else {
86
- execSync(`tar -xzf ${tempPath} -C ${path.dirname(destPath)}`);
87
- }
88
-
89
- fs.unlinkSync(tempPath);
90
-
91
- if (platform !== 'Windows') {
92
- execSync(`chmod +x ${destPath}`);
93
- }
94
-
95
- console.log(`Installed ${platform} binary to ${destPath}`);
96
- };
97
-
98
- const main = async () => {
99
- try {
100
- await installBinary();
101
- process.exit(0);
102
- } catch (err) {
103
- console.error('Error:', err.message);
104
- process.exit(1);
105
- }
106
- };
107
-
108
- main();