@ekkolyth/miso 0.2.6 → 0.3.2

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  the agnostic package manager
4
4
 
5
- <img src="https://raw.githubusercontent.com/ekkolyth/miso/main/internal/assets/miso.png" alt="miso" width="200"/>
5
+ <img src="https://raw.githubusercontent.com/ekkolyth/miso/main/apps/miso/internal/assets/miso.png" alt="miso" width="200"/>
6
6
 
7
7
  Miso is a tiny cli tool that let's you stop worrying about which package manager your projects are using. Use the tools you and your team want, without the hassle.
8
8
 
@@ -14,21 +14,12 @@ Miso doesn't care where you work or what tools you use. It sits as a light wrapp
14
14
 
15
15
  ### Installation
16
16
 
17
- #### Install via Go
18
-
19
- ```bash
20
- go install github.com/ekkolyth/miso@latest
21
- ```
22
-
23
17
  #### Install via npm
18
+
24
19
  Global Install (recommended)
25
- ```bash
26
- npm install -g @ekkolyth/miso
27
- ```
28
20
 
29
- Local Install
30
21
  ```bash
31
- npm install @ekkolyth/miso@latest
22
+ npm install -g @ekkolyth/miso
32
23
  ```
33
24
 
34
25
  Then run `miso init` to add miso to your project:
@@ -37,31 +28,57 @@ Then run `miso init` to add miso to your project:
37
28
  miso init
38
29
  ```
39
30
 
40
- **Note:** If you installed locally, use `npx miso init`.
41
-
42
- ## Supported commands
43
-
44
- - `miso init`
45
- - `miso version`
46
- - `miso install`
47
- - `miso add <pkg>`
48
- - `miso remove <pkg>`
49
- - `miso dev <args>`
50
- - `miso <script> [-- <args>]`
51
-
52
- ## `miso.json`
31
+ ### Example miso.json (Kitchen Sink)
53
32
 
54
33
  ```json
55
34
  {
56
- "packageManager": "pnpm",
57
- "projectName": "miso-demo",
58
- "scripts": {
59
- "dev": "pnpm dev --host",
60
- "lint": "pnpm eslint ."
61
- }
35
+ "$schema": "https://misojs.dev/miso.schema.json",
36
+ "package-manager": "bun",
37
+ "name": "my-project",
38
+ "scripts": "./scripts",
39
+ "shell": "bash",
40
+ "flags": {
41
+ "add": ["--dev"],
42
+ "remove": [],
43
+ "install": ["--frozen-lockfile"],
44
+ "dev": ["--env"]
45
+ },
46
+ "env": {
47
+ "path": [".env.local", ".env"],
48
+ "required": "all",
49
+ "variables": {
50
+ "PORT": "port",
51
+ "DATABASE_URL": "url",
52
+ "API_KEY": {
53
+ "type": "string",
54
+ "min": 1,
55
+ "max": 32
56
+ },
57
+ "NODE_ENV": {
58
+ "type": "enum",
59
+ "values": ["development", "production", "test"],
60
+ "optional": true
61
+ },
62
+ "REDIS_URL": {
63
+ "type": "url",
64
+ "schemes": ["redis", "rediss"]
65
+ },
66
+ "RATE_LIMIT": {
67
+ "type": "int+",
68
+ "min": 1,
69
+ "max": 1000
70
+ },
71
+ "FEATURE_FLAGS": "json",
72
+ "USER_ID": "uuid",
73
+ "ADMIN_EMAIL": "email",
74
+ "DEBUG_MODE": "bool",
75
+ "SLUG": {
76
+ "type": "pattern",
77
+ "pattern": "^[a-z0-9-]+$"
78
+ }
79
+ }
80
+ }
62
81
  }
63
82
  ```
64
83
 
65
- You can edit this file at any time to switch managers or add more scripts. If a lockfile _is_ present, Miso will still generate the config automatically so you have something to customize later.
66
-
67
- ## Contributions welcome!
84
+ ### Contributions welcome!
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "bin": {
3
- "miso": "./miso.mjs",
4
- "misox": "./misox.mjs"
3
+ "miso": "miso.mjs",
4
+ "misox": "misox.mjs"
5
+ },
6
+ "scripts": {
7
+ "postinstall": "node scripts/postinstall.mjs"
5
8
  },
6
9
  "description": "the agnostic package manager",
10
+ "homepage": "https://misojs.dev",
7
11
  "files": [
8
12
  "README.md",
9
13
  "miso.mjs",
10
14
  "misox.mjs",
15
+ "scripts/postinstall.mjs",
11
16
  "bin/miso-darwin-amd64",
12
17
  "bin/miso-darwin-arm64",
13
18
  "bin/miso-linux-amd64",
@@ -25,5 +30,5 @@
25
30
  "type": "git",
26
31
  "url": "git+https://github.com/ekkolyth/miso.git"
27
32
  },
28
- "version": "0.2.6"
33
+ "version": "0.3.2"
29
34
  }
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall: automatically install shell completions.
5
+ * Runs on npm install (global or local) and when using the local install script.
6
+ */
7
+
8
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
9
+ import { dirname, join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+
14
+ if (!process.env.HOME) process.exit(0);
15
+
16
+ const SCRIPTS = {
17
+ bash: `_miso_completion() {
18
+ local cur prev
19
+ cur="${"$"}{COMP_WORDS[COMP_CWORD]}"
20
+ if [ $COMP_CWORD -ge 1 ]; then
21
+ prev="${"$"}{COMP_WORDS[COMP_CWORD-1]}"
22
+ else
23
+ prev="miso"
24
+ fi
25
+ COMPREPLY=($(miso __complete miso "$cur" "$prev" 2>/dev/null))
26
+ }
27
+
28
+ complete -F _miso_completion miso
29
+ `,
30
+ zsh: `_miso() {
31
+ local cur="${"$"}{words[CURRENT]}"
32
+ local prev="${"$"}{words[CURRENT-1]}"
33
+ local -a completions
34
+ completions=("${"$"}{(f)$(miso __complete miso "$cur" "$prev" 2>/dev/null)}")
35
+ compadd -a completions
36
+ }
37
+
38
+ compdef _miso miso
39
+ `,
40
+ fish: `function __miso_complete
41
+ set -l cl (commandline -cp)
42
+ set -l tokens (string split " " -- $cl)
43
+ set -l cur ""
44
+ set -l prev "miso"
45
+ if test (count $tokens) -ge 2
46
+ set cur $tokens[-1]
47
+ set prev $tokens[-2]
48
+ else if test (count $tokens) -eq 1
49
+ set prev $tokens[1]
50
+ end
51
+ miso __complete miso "$cur" "$prev"
52
+ end
53
+
54
+ complete -c miso -a '(__miso_complete)'
55
+ `,
56
+ };
57
+
58
+ function getShell() {
59
+ const shell = process.env.SHELL || '';
60
+ const base = shell.split('/').pop() || '';
61
+ if (base.startsWith('bash')) return 'bash';
62
+ if (base.startsWith('zsh')) return 'zsh';
63
+ if (base.startsWith('fish')) return 'fish';
64
+ return null;
65
+ }
66
+
67
+ function getConfigPath(shell) {
68
+ const home = process.env.HOME;
69
+ switch (shell) {
70
+ case 'bash': return join(home, '.bashrc');
71
+ case 'zsh': return join(home, '.zshrc');
72
+ case 'fish': return join(home, '.config', 'fish', 'config.fish');
73
+ default: return null;
74
+ }
75
+ }
76
+
77
+ function isInstalled(configPath, shell) {
78
+ if (!existsSync(configPath)) return false;
79
+ const content = readFileSync(configPath, 'utf8');
80
+ if (shell === 'bash') return content.includes('_miso_completion');
81
+ if (shell === 'zsh') return content.includes('compdef _miso miso');
82
+ if (shell === 'fish') return content.includes('complete -c miso');
83
+ return false;
84
+ }
85
+
86
+ const shell = getShell();
87
+ if (!shell) process.exit(0);
88
+
89
+ const configPath = getConfigPath(shell);
90
+ if (!configPath) process.exit(0);
91
+
92
+ if (isInstalled(configPath, shell)) process.exit(0);
93
+
94
+ const script = SCRIPTS[shell];
95
+ const toAppend = `\n# Miso shell completion\n${script}`;
96
+
97
+ try {
98
+ const content = existsSync(configPath) ? readFileSync(configPath, 'utf8') : '';
99
+ writeFileSync(configPath, content + toAppend, 'utf8');
100
+ } catch {
101
+ process.exit(0);
102
+ }