@ossy/cli 1.16.9 → 1.16.10

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 (3) hide show
  1. package/README.md +23 -7
  2. package/package.json +6 -4
  3. package/src/index.js +94 -6
package/README.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # @ossy/cli
2
2
 
3
- Unified CLI for the Ossy platform: app build and CMS workflows.
3
+ Unified CLI for the Ossy platform.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @ossy/cli
9
+ ```
10
+
11
+ After install, the `ossy` command is on your PATH:
12
+
13
+ ```bash
14
+ ossy --version
15
+ ossy --help
16
+ ossy <command> --help
17
+ ```
18
+
19
+ For one-off use without installing, you can still run `npx @ossy/cli <command>`.
4
20
 
5
21
  ## Commands
6
22
 
@@ -15,7 +31,7 @@ Unified CLI for the Ossy platform: app build and CMS workflows.
15
31
  ## App: build
16
32
 
17
33
  ```bash
18
- npx @ossy/cli build
34
+ ossy build
19
35
  ```
20
36
 
21
37
  Options: e.g. `--config` for `src/config.js`. See `packages/app/README.md` for app build behavior.
@@ -51,7 +67,7 @@ Container deploys assume **Amazon ECR** in **`deployments.json`** (`registry` li
51
67
  cd packages/my-website
52
68
  export OSSY_API_KEY=<ossy-api-jwt> # or pass --authentication <ossy-api-jwt>
53
69
 
54
- npx @ossy/cli publish \
70
+ ossy publish \
55
71
  --platforms-path ../infrastructure/platforms.json \
56
72
  --deployments-path "../infrastructure/deployments/**/*.json"
57
73
  ```
@@ -77,7 +93,7 @@ Upload resource templates to your workspace so they can be used in the UI.
77
93
  Prefer **`--authentication` / `-a`** for the **Ossy API JWT** (same as **`publish`**); it matches **`OSSY_API_KEY`** in CI.
78
94
 
79
95
  ```bash
80
- npx @ossy/cli cms upload --authentication <ossy-api-jwt> --config src/config.js
96
+ ossy cms upload --authentication <ossy-api-jwt> --config src/config.js
81
97
  # optional: --api-url https://api.ossy.se/api/v0 (or set OSSY_API_URL)
82
98
  # In CI you may omit --authentication when OSSY_API_KEY is set
83
99
  ```
@@ -119,7 +135,7 @@ jobs:
119
135
  Validate an ossy config file before uploading:
120
136
 
121
137
  ```bash
122
- npx @ossy/cli cms validate --config src/config.js
138
+ ossy cms validate --config src/config.js
123
139
  ```
124
140
 
125
141
  When **`--config`** is omitted, **`./src/config.js`** is used if it exists.
@@ -137,8 +153,8 @@ When **`--config`** is omitted, **`./src/config.js`** is used if it exists.
137
153
  Scaffold a new Ossy app:
138
154
 
139
155
  ```bash
140
- npx @ossy/cli init
141
- npx @ossy/cli init my-app
156
+ ossy init
157
+ ossy init my-app
142
158
  ```
143
159
 
144
160
  Creates `src/home.page.jsx`, `src/config.js`, and `package.json` (if missing).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/cli",
3
- "version": "1.16.9",
3
+ "version": "1.16.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ossy-se/packages.git"
@@ -15,10 +15,12 @@
15
15
  },
16
16
  "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
17
17
  "license": "MIT",
18
- "bin": "./src/index.js",
18
+ "bin": {
19
+ "ossy": "./src/index.js"
20
+ },
19
21
  "dependencies": {
20
22
  "@babel/parser": "^7.28.6",
21
- "@ossy/app": "^1.16.9",
23
+ "@ossy/app": "^1.16.10",
22
24
  "arg": "^5.0.2",
23
25
  "glob": "^10.3.10"
24
26
  },
@@ -30,5 +32,5 @@
30
32
  "/src",
31
33
  "README.md"
32
34
  ],
33
- "gitHead": "be7612ac40cc49e027b0e417938cda738e19cd58"
35
+ "gitHead": "5821b2cea64c9ca0ece35d65a463006852abf167"
34
36
  }
package/src/index.js CHANGED
@@ -1,17 +1,104 @@
1
1
  #!/usr/bin/env node
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
2
5
  import { build } from '@ossy/app'
3
6
  import * as Cms from './cms/cli.js'
4
7
  import * as Init from './init/cli.js'
5
8
  import { publish } from './publish/cli.js'
6
9
  import * as Registry from './registry/cli.js'
7
10
 
8
- const [,, command, ...restArgs] = process.argv
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
12
+ const pkg = JSON.parse(
13
+ fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')
14
+ )
9
15
 
10
- if (!command) {
11
- console.error(
12
- '[@ossy/cli] No command provided. Usage: ossy build [--worker] | publish | registry <subcommand> | init | cms <subcommand>'
13
- )
14
- process.exit(1)
16
+ const HELP = `ossy ${pkg.version}
17
+ Command line tool for the Ossy platform.
18
+
19
+ Usage:
20
+ ossy <command> [options]
21
+
22
+ Commands:
23
+ init [dir] Scaffold a new Ossy app
24
+ build Production build of the app in the current directory
25
+ publish Deploy a site and upload templates / site artifacts
26
+ cms <subcommand> Resource template workflows: upload | validate
27
+ registry <subcommand> Container registry helpers: ecr-push-credentials
28
+
29
+ Options:
30
+ -h, --help Show this help, or for a command: ossy <command> --help
31
+ -v, --version Print the installed version
32
+ `
33
+
34
+ const SUBCOMMAND_HELP = {
35
+ init: `ossy init [dir]
36
+ Scaffold a new Ossy app in [dir] (defaults to current directory).
37
+ Creates src/home.page.jsx, src/config.js, and package.json (if missing).
38
+ `,
39
+ build: `ossy build
40
+ Run the production build for the app in the current directory.
41
+ See the @ossy/app README for build options.
42
+ `,
43
+ publish: `ossy publish [options]
44
+ Deploy via @ossy/deployment-tools, then optionally upload resource templates
45
+ and site artifacts.
46
+
47
+ Options:
48
+ -a, --authentication Ossy API JWT (or set OSSY_API_KEY)
49
+ -d, --domain Site domain
50
+ -p, --platform Target deployment platform
51
+ -c, --config Path to src/config.js
52
+ --platforms-path Path to platforms.json
53
+ --deployments-path Glob for deployments JSON files
54
+ --all Deploy all sites for the platform
55
+ --skip-resource-templates Skip post-deploy resource-template upload
56
+ --skip-site-artifacts Skip post-deploy site-artifact upload
57
+ --site-artifacts-build-dir Override the site build directory
58
+ --api-url API base URL for CMS calls
59
+ `,
60
+ cms: `ossy cms <subcommand>
61
+ Subcommands:
62
+ upload Upload resource templates from src/config.js to the workspace
63
+ validate Validate ossy app config and resource templates locally
64
+
65
+ Options (upload):
66
+ -a, --authentication Ossy API JWT (or set OSSY_API_KEY)
67
+ -c, --config Path to src/config.js
68
+ --api-url API base URL for CMS calls
69
+
70
+ Options (validate):
71
+ -c, --config Path to src/config.js
72
+ `,
73
+ registry: `ossy registry <subcommand>
74
+ Subcommands:
75
+ ecr-push-credentials Fetch a short-lived ECR password for docker login
76
+
77
+ Options:
78
+ -a, --authentication Ossy API JWT (or set OSSY_API_KEY)
79
+ --workspace-id Workspace id
80
+ --format json | github-actions
81
+ `,
82
+ }
83
+
84
+ const isHelpFlag = (a) => a === '--help' || a === '-h'
85
+ const isVersionFlag = (a) => a === '--version' || a === '-v'
86
+
87
+ const [, , command, ...restArgs] = process.argv
88
+
89
+ if (command === undefined || isHelpFlag(command)) {
90
+ console.log(HELP)
91
+ process.exit(0)
92
+ }
93
+
94
+ if (isVersionFlag(command)) {
95
+ console.log(pkg.version)
96
+ process.exit(0)
97
+ }
98
+
99
+ if (restArgs.some(isHelpFlag) && SUBCOMMAND_HELP[command]) {
100
+ console.log(SUBCOMMAND_HELP[command])
101
+ process.exit(0)
15
102
  }
16
103
 
17
104
  const run = async () => {
@@ -36,6 +123,7 @@ const run = async () => {
36
123
  return
37
124
  }
38
125
  console.error(`[@ossy/cli] Unknown command: ${command}`)
126
+ console.error('Run `ossy --help` for available commands.')
39
127
  process.exit(1)
40
128
  }
41
129