@dockstat/repo-cli 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dockstat/repo-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A CLI helper for administering DockStat Repositories",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -10,21 +10,24 @@
10
10
  "README.md"
11
11
  ],
12
12
  "bin": {
13
- "dockstat-repo": "./dist/dockstore-repo-cli"
13
+ "dockstat-repo": "./dist/dockstat-repo-cli"
14
+ },
15
+ "exports": {
16
+ "./types": "./src/types.ts"
14
17
  },
15
18
  "scripts": {
16
- "build": "bun build --target=bun --compile --outfile=dist/dockstore-repo-cli src/index.ts",
17
- "prepublishOnly": "bun run build"
19
+ "build": "bun build --target=bun --compile --outfile=dist/dockstat-repo-cli src/index.ts",
20
+ "publish": "bun run build && bun pm pack --destination ./dist && npm publish --access public ./dist/*.tgz ; rm -r ./dist"
18
21
  },
19
22
  "devDependencies": {
20
23
  "@types/bun": "latest",
21
- "@dockstat/typings": "workspace:*"
24
+ "@dockstat/typings": "1.1.0"
22
25
  },
23
26
  "peerDependencies": {
24
27
  "typescript": "^5"
25
28
  },
26
29
  "dependencies": {
27
- "@dockstat/utils": "workspace:*",
30
+ "@dockstat/utils": "1.0.0",
28
31
  "@commander-js/extra-typings": "^14.0.0",
29
32
  "commander": "^14.0.2",
30
33
  "ajv": "^8.17.1",
@@ -32,43 +32,54 @@ export const badgesCommand = new Command("badges")
32
32
 
33
33
  const badges: { name: string; svg: string }[] = []
34
34
 
35
- if (options.plugins) {
36
- const count = content.plugins.length
37
- badges.push({
35
+ // Right after `const badges: { name: string; svg: string }[] = []`
36
+
37
+ type CountBadgeKey = "plugins" | "themes" | "stacks"
38
+
39
+ const countBadgeConfigs: {
40
+ optionKey: CountBadgeKey
41
+ name: string
42
+ label: string
43
+ color: string
44
+ icon: IconName
45
+ getCount: () => number
46
+ }[] = [
47
+ {
48
+ optionKey: "plugins",
38
49
  name: "plugins",
39
- svg: createBadge({
40
- label: "plugins",
41
- message: count.toString(),
42
- color: count > 0 ? COLORS.blue : COLORS.lightgrey,
43
- icon: "puzzle",
44
- style,
45
- }),
46
- })
47
- }
48
-
49
- if (options.themes) {
50
- const count = content.themes.length
51
- badges.push({
50
+ label: "plugins",
51
+ color: COLORS.blue,
52
+ icon: "puzzle",
53
+ getCount: () => content.plugins.length,
54
+ },
55
+ {
56
+ optionKey: "themes",
52
57
  name: "themes",
53
- svg: createBadge({
54
- label: "themes",
55
- message: count.toString(),
56
- color: count > 0 ? COLORS.purple : COLORS.lightgrey,
57
- icon: "palette",
58
- style,
59
- }),
60
- })
61
- }
62
-
63
- if (options.stacks) {
64
- const count = content.stacks.length
65
- badges.push({
58
+ label: "themes",
59
+ color: COLORS.purple,
60
+ icon: "palette",
61
+ getCount: () => content.themes.length,
62
+ },
63
+ {
64
+ optionKey: "stacks",
66
65
  name: "stacks",
66
+ label: "stacks",
67
+ color: COLORS.teal,
68
+ icon: "layers",
69
+ getCount: () => content.stacks.length,
70
+ },
71
+ ]
72
+
73
+ for (const cfg of countBadgeConfigs) {
74
+ if (!options[cfg.optionKey]) continue
75
+ const count = cfg.getCount()
76
+ badges.push({
77
+ name: cfg.name,
67
78
  svg: createBadge({
68
- label: "stacks",
79
+ label: cfg.label,
69
80
  message: count.toString(),
70
- color: count > 0 ? COLORS.teal : COLORS.lightgrey,
71
- icon: "layers",
81
+ color: count > 0 ? cfg.color : COLORS.lightgrey,
82
+ icon: cfg.icon,
72
83
  style,
73
84
  }),
74
85
  })
@@ -17,6 +17,8 @@ export const serveCommand = new Command("serve")
17
17
 
18
18
  let filePath = decodeURIComponent(url.pathname)
19
19
 
20
+ filePath = filePath.replaceAll("../", "/")
21
+
20
22
  if (filePath.charAt(0) === "/") {
21
23
  filePath = filePath.replace("/", "")
22
24
  }
package/src/types.ts CHANGED
@@ -8,7 +8,7 @@ export interface Opts extends Omit<CreateRepoType, "source"> {
8
8
  stacks: { dir: string }
9
9
  }
10
10
 
11
- export interface RepoFile {
11
+ export interface RepoFile extends Record<string, unknown> {
12
12
  config: Omit<Opts, "root">
13
13
  content: {
14
14
  plugins: PluginMetaType[]