@dual-os/cli 0.12.3 → 0.13.1
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/openapi/emit.d.ts +1 -1
- package/dist/openapi/emit.d.ts.map +1 -1
- package/dist/openapi/emit.js +20 -19
- package/dist/openapi/emit.js.map +1 -1
- package/dist/openapi/schema.d.ts.map +1 -1
- package/dist/openapi/schema.js +3 -2
- package/dist/openapi/schema.js.map +1 -1
- package/dist/plugin/archive.d.ts +1 -0
- package/dist/plugin/archive.d.ts.map +1 -1
- package/dist/plugin/archive.js +2 -0
- package/dist/plugin/archive.js.map +1 -1
- package/dist/plugin/bundle.d.ts.map +1 -1
- package/dist/plugin/bundle.js +15 -6
- package/dist/plugin/bundle.js.map +1 -1
- package/dist/plugin/publication.d.ts.map +1 -1
- package/dist/plugin/publication.js +4 -1
- package/dist/plugin/publication.js.map +1 -1
- package/package.json +4 -4
- package/src/openapi/emit.ts +37 -24
- package/src/openapi/schema.ts +3 -2
- package/src/plugin/archive.ts +2 -0
- package/src/plugin/bundle.ts +34 -6
- package/src/plugin/publication.ts +13 -0
package/src/plugin/archive.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const Artifact = Schema.Struct({
|
|
|
32
32
|
file: Schema.String,
|
|
33
33
|
plugin: Schema.String,
|
|
34
34
|
published: Schema.Literal(false),
|
|
35
|
+
sdkVersion: Schema.String,
|
|
35
36
|
size: Schema.Finite,
|
|
36
37
|
version: Schema.String,
|
|
37
38
|
});
|
|
@@ -249,6 +250,7 @@ export const layer = Layer.effect(
|
|
|
249
250
|
file,
|
|
250
251
|
plugin: original.plugin,
|
|
251
252
|
published: false,
|
|
253
|
+
sdkVersion: compiled.sdkVersion,
|
|
252
254
|
size: bytes.length,
|
|
253
255
|
version: original.version,
|
|
254
256
|
} satisfies Artifact;
|
package/src/plugin/bundle.ts
CHANGED
|
@@ -447,23 +447,51 @@ export const make = Effect.gen(function* () {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
if (source.startsWith(`${input}${path.sep}`)) continue;
|
|
450
|
+
const segments = source.split(path.sep);
|
|
451
|
+
const modules = segments.lastIndexOf("node_modules");
|
|
452
|
+
const packageRoot =
|
|
453
|
+
modules === -1
|
|
454
|
+
? undefined
|
|
455
|
+
: Array.join(
|
|
456
|
+
segments.slice(0, modules + (segments[modules + 1]?.startsWith("@") ? 3 : 2)),
|
|
457
|
+
path.sep,
|
|
458
|
+
);
|
|
450
459
|
const owner = Effect.fnUntraced(function* (
|
|
451
460
|
directory: string,
|
|
452
461
|
): Effect.fn.Return<string, PlatformError.PlatformError | PluginPackage.PackageError> {
|
|
453
|
-
|
|
462
|
+
const manifest = path.join(directory, "package.json");
|
|
463
|
+
if (yield* fs.exists(manifest)) {
|
|
464
|
+
if (packageRoot) return directory;
|
|
465
|
+
const candidate = yield* Schema.decodeEffect(Schema.fromJsonString(Schema.JsonObject))(
|
|
466
|
+
yield* fs.readFileString(manifest),
|
|
467
|
+
).pipe(
|
|
468
|
+
Effect.mapError(cause =>
|
|
469
|
+
PluginPackage.fromCause(
|
|
470
|
+
cause,
|
|
471
|
+
`Invalid dependency manifest ${manifest} for ${source}`,
|
|
472
|
+
),
|
|
473
|
+
),
|
|
474
|
+
);
|
|
475
|
+
if (Object.hasOwn(candidate, "name")) return directory;
|
|
476
|
+
}
|
|
454
477
|
const parent = path.dirname(directory);
|
|
455
|
-
if (parent === directory)
|
|
478
|
+
if (parent === directory || directory === packageRoot)
|
|
456
479
|
return yield* PluginPackage.PackageError.make({
|
|
457
|
-
message: `Dependency has no package manifest: ${source}`,
|
|
480
|
+
message: `Dependency has no package manifest: ${source}; searched ${manifest}`,
|
|
458
481
|
});
|
|
459
482
|
return yield* owner(parent);
|
|
460
483
|
});
|
|
461
|
-
const directory = yield* owner(path.dirname(source));
|
|
484
|
+
const directory = yield* owner(packageRoot ?? path.dirname(source));
|
|
462
485
|
if (MutableHashMap.has(packages, directory)) continue;
|
|
463
|
-
const
|
|
486
|
+
const manifest = path.join(directory, "package.json");
|
|
487
|
+
const pkg = yield* json(manifest).pipe(
|
|
488
|
+
Effect.mapError(cause =>
|
|
489
|
+
PluginPackage.fromCause(cause, `Invalid dependency manifest ${manifest} for ${source}`),
|
|
490
|
+
),
|
|
491
|
+
);
|
|
464
492
|
if (!pkg.name || !pkg.license)
|
|
465
493
|
return yield* PluginPackage.PackageError.make({
|
|
466
|
-
message: `Dependency lacks name/license metadata: ${
|
|
494
|
+
message: `Dependency lacks name/license metadata: ${manifest} for ${source}`,
|
|
467
495
|
});
|
|
468
496
|
const licenseFiles = (yield* fs.glob("{LICENSE,LICENCE,COPYING,NOTICE}{,.md,.txt}", {
|
|
469
497
|
root: directory,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Console,
|
|
2
3
|
Context,
|
|
3
4
|
Effect,
|
|
4
5
|
FileSystem,
|
|
@@ -11,6 +12,9 @@ import {
|
|
|
11
12
|
} from "effect";
|
|
12
13
|
|
|
13
14
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
15
|
+
import semver from "semver";
|
|
16
|
+
|
|
17
|
+
import sdkPackage from "@dual-os/sdk/package.json" with { type: "json" };
|
|
14
18
|
|
|
15
19
|
import { CliCredentials } from "#auth/credentials";
|
|
16
20
|
import { CliDestination } from "#auth/destination";
|
|
@@ -88,6 +92,15 @@ export const layer = Layer.effect(
|
|
|
88
92
|
"plugin.tgz",
|
|
89
93
|
);
|
|
90
94
|
const artifact = yield* archives.build(directory, file);
|
|
95
|
+
if (
|
|
96
|
+
semver.lt(
|
|
97
|
+
artifact.sdkVersion,
|
|
98
|
+
`${semver.major(sdkPackage.version)}.${semver.minor(sdkPackage.version)}.0`,
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
yield* Console.error(
|
|
102
|
+
`Warning: this plugin uses @dual-os/sdk ${artifact.sdkVersion}, an older minor than this CLI's ${sdkPackage.version}. Dual stops accepting it for publication when the next SDK minor ships; run \`bun add @dual-os/sdk@${sdkPackage.version}\`.`,
|
|
103
|
+
);
|
|
91
104
|
const response = yield* client.execute(
|
|
92
105
|
pipe(
|
|
93
106
|
HttpClientRequest.post(new URL("/api/cli/plugins/push", target.deployment).href),
|