@phreshos/cli 0.1.2 → 0.1.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/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ import init from "./init.js";
7
7
  import pack from "./pack.js";
8
8
  import uninstall from "./uninstall.js";
9
9
  const { version } = metadata;
10
+ const coreRange = metadata.dependencies["@phreshos/core"];
10
11
  /**
11
12
  * One command system.
12
13
  *
@@ -53,7 +54,7 @@ const commands = [
53
54
  clientDevelopmentUrl: text(options, "client-development-url"),
54
55
  clientDevelopmentStartCommand: text(options, "client-development-start-command"),
55
56
  force: options.force === true
56
- }, process.cwd(), version)
57
+ }, process.cwd(), coreRange)
57
58
  },
58
59
  {
59
60
  name: "pack",
package/dist/init.js CHANGED
@@ -13,7 +13,7 @@ import { resolve } from "node:path";
13
13
  * same config and ensure the matching Core dependency through this one
14
14
  * function.
15
15
  */
16
- export default async function init(options = {}, directory = process.cwd(), coreVersion = "0.1.0") {
16
+ export default async function init(options = {}, directory = process.cwd(), coreRange = "^0.1.0") {
17
17
  const manifest = await readManifest(directory);
18
18
  const path = resolve(directory, configFile);
19
19
  const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
@@ -138,7 +138,7 @@ export default async function init(options = {}, directory = process.cwd(), core
138
138
  const config = server
139
139
  ? { ...described, server, ...client && { client } }
140
140
  : { ...described, client: client };
141
- await ensureProjectDependency("@phreshos/core", coreVersion, directory);
141
+ await ensureProjectDependency("@phreshos/core", coreRange, directory);
142
142
  writeFileSync(path, compose(config));
143
143
  heading(configFile, "created");
144
144
  if (config.server)
@@ -11,17 +11,17 @@ export function projectScript(directory, declared, script) {
11
11
  *
12
12
  * A CLI running from this repository uses its sibling dev-kit, so Program
13
13
  * authoring can be exercised before anything is published. An installed CLI
14
- * has no such sibling and names the matching registry version instead. This
14
+ * has no such sibling and names the declared registry range instead. This
15
15
  * decision belongs here once for both `init` and the future `create` command.
16
16
  */
17
- export default async function ensureProjectDependency(name, version, directory = process.cwd()) {
17
+ export default async function ensureProjectDependency(name, range, directory = process.cwd()) {
18
18
  const manifestPath = resolve(directory, "package.json");
19
19
  const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
20
20
  if (manifest.dependencies?.[name] || manifest.devDependencies?.[name])
21
21
  return;
22
22
  const manager = packageManager(directory, manifest.packageManager);
23
- const source = packageSource(name, version);
24
- line("dependency", name, `${manager.name}, ${source.local ? "local dev-kit" : `^${version}`}`);
23
+ const source = packageSource(name, range);
24
+ line("dependency", name, `${manager.name}, ${source.local ? "local dev-kit" : range}`);
25
25
  await new Promise(function (settle, refuse) {
26
26
  const child = spawn(manager.name, [...manager.args, source.specifier], {
27
27
  cwd: directory,
@@ -40,12 +40,15 @@ export default async function ensureProjectDependency(name, version, directory =
40
40
  });
41
41
  console.log("");
42
42
  }
43
- function packageSource(name, version) {
43
+ function packageSource(name, range) {
44
44
  const directory = resolve(import.meta.dirname, "..", "..", localDirectories[name]);
45
45
  const manifest = manifestAt(directory);
46
- if (manifest?.name === name && manifest.version === version)
46
+ if (manifest?.name === name && manifest.version && accepts(range, manifest.version))
47
47
  return { specifier: directory, local: true };
48
- return { specifier: `${name}@^${version}`, local: false };
48
+ return { specifier: `${name}@${range}`, local: false };
49
+ }
50
+ function accepts(range, version) {
51
+ return range === "workspace:*" || range === version || range === `^${version}` || range === `~${version}`;
49
52
  }
50
53
  function manifestAt(directory) {
51
54
  const path = resolve(directory, "package.json");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@phreshos/cli",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "description": "The Phresh command-line interface for Program projects and system management.",
6
6
  "scripts": {
7
7
  "build": "tsc --noEmit false --outDir dist --rootDir source --rewriteRelativeImportExtensions true --allowImportingTsExtensions true",