velocity-cms 0.0.0-stage → 0.1.0-beta.11
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 +21 -0
- package/README.md +17 -2
- package/bin/install.mjs +23 -0
- package/bin/velocity-cms.mjs +38 -0
- package/package.json +24 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Southwell Media
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# velocity-cms
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The command that adds [Velocity CMS](https://github.com/Velocity-Astro/velocity-cms) to an Astro site.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx velocity-cms init you@example.com "Your Name"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It installs `@velocity-astro/cms-astro` with the site's own package manager, writes a secret to `.env`, adds the integration to the Astro config and makes you the site's owner. Run again, it changes nothing that is there.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx velocity-cms owner <email> <name> # the site's first owner, with a link that signs them in
|
|
13
|
+
npx velocity-cms link <email> # a new sign-in link for someone who has access
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Docs: https://docs.deployvelocity.com/cms/
|
|
17
|
+
|
|
18
|
+
MIT
|
package/bin/install.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** The package a site installs. Its own `velocity-cms` command does the work once it is there. */
|
|
5
|
+
export const PACKAGE = '@velocity-astro/cms-astro';
|
|
6
|
+
|
|
7
|
+
/** The folder of the CMS as this site has it installed, looking up from `dir`, or `null`. */
|
|
8
|
+
export function installed(dir) {
|
|
9
|
+
for (let at = path.resolve(dir); ; at = path.dirname(at)) {
|
|
10
|
+
const found = path.join(at, 'node_modules', ...PACKAGE.split('/'));
|
|
11
|
+
if (fs.existsSync(path.join(found, 'package.json'))) return found;
|
|
12
|
+
if (path.dirname(at) === at) return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The command that adds a package to this site, by the lockfile the site keeps. npm when it keeps none. */
|
|
17
|
+
export function addCommand(dir, spec) {
|
|
18
|
+
const has = (file) => fs.existsSync(path.join(dir, file));
|
|
19
|
+
if (has('pnpm-lock.yaml')) return ['pnpm', ['add', spec]];
|
|
20
|
+
if (has('yarn.lock')) return ['yarn', ['add', spec]];
|
|
21
|
+
if (has('bun.lock') || has('bun.lockb')) return ['bun', ['add', spec]];
|
|
22
|
+
return ['npm', ['install', spec]];
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `npx velocity-cms <command>` in a site that may not have the CMS yet. `init` installs it with
|
|
4
|
+
* the site's own package manager; every command is then handed to the CMS the site has, so the
|
|
5
|
+
* command and the site's code are always the same version.
|
|
6
|
+
*/
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { PACKAGE, addCommand, installed } from './install.mjs';
|
|
12
|
+
|
|
13
|
+
const dir = process.cwd();
|
|
14
|
+
const args = process.argv.slice(2);
|
|
15
|
+
const windows = process.platform === 'win32';
|
|
16
|
+
|
|
17
|
+
let cms = installed(dir);
|
|
18
|
+
if (!cms && args[0] === 'init') {
|
|
19
|
+
if (!fs.existsSync(path.join(dir, 'package.json'))) {
|
|
20
|
+
console.error('There is no package.json here. Run this in the folder of your Astro site.');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8'));
|
|
24
|
+
const [command, parts] = addCommand(dir, `${PACKAGE}@${version}`);
|
|
25
|
+
console.log(`Installing ${PACKAGE} with ${command}.\n`);
|
|
26
|
+
const done = spawnSync(command, parts, { cwd: dir, stdio: 'inherit', shell: windows });
|
|
27
|
+
if (done.status !== 0) {
|
|
28
|
+
console.error(`\n${PACKAGE} could not be installed. Install it yourself, then run this again.`);
|
|
29
|
+
process.exit(done.status ?? 1);
|
|
30
|
+
}
|
|
31
|
+
cms = installed(dir);
|
|
32
|
+
}
|
|
33
|
+
if (!cms) {
|
|
34
|
+
console.error(`This site does not have Velocity CMS yet. To add it:\n\n npx velocity-cms init\n`);
|
|
35
|
+
process.exit(args.length === 0 || args[0] === 'help' ? 0 : 1);
|
|
36
|
+
}
|
|
37
|
+
const run = spawnSync(process.execPath, [path.join(cms, 'bin', 'velocity-cms.mjs'), ...args], { cwd: dir, stdio: 'inherit' });
|
|
38
|
+
process.exit(run.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "velocity-cms",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-beta.11",
|
|
4
|
+
"description": "The command that adds Velocity CMS to an Astro site: npx velocity-cms init",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Velocity-Astro/velocity-cms.git",
|
|
10
|
+
"directory": "packages/velocity-cms"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://docs.deployvelocity.com/cms/",
|
|
13
|
+
"bugs": "https://github.com/Velocity-Astro/velocity-cms/issues",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22.23.4"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"velocity-cms": "bin/velocity-cms.mjs"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin",
|
|
25
|
+
"!bin/**/*.test.*"
|
|
26
|
+
]
|
|
6
27
|
}
|