Unify scoped development with ordinary Workspace authoring commands
This commit is contained in:
@@ -16,8 +16,11 @@ export async function prepareDevelopmentSources(options: {
|
||||
directory: string;
|
||||
cacheDirectory: string;
|
||||
locations?: Record<string, string>;
|
||||
workspaceId?: string;
|
||||
}) {
|
||||
const source = workspaceSourcePin(options.source);
|
||||
if (options.workspaceId !== undefined && !/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(options.workspaceId))
|
||||
throw Error("Development source binding requires a Workspace UUID");
|
||||
const destination = path.resolve(options.directory);
|
||||
const cache = path.resolve(options.cacheDirectory);
|
||||
if (cache === destination || cache.startsWith(destination + path.sep))
|
||||
@@ -43,7 +46,8 @@ export async function prepareDevelopmentSources(options: {
|
||||
const parent = path.dirname(destination);
|
||||
await mkdir(parent, { recursive: true });
|
||||
const staging = await mkdtemp(path.join(parent, ".development-sources-"));
|
||||
const workspaceId = randomUUID();
|
||||
// This local association does not create or grant access to a hosted Graph.
|
||||
const workspaceId = options.workspaceId ?? randomUUID();
|
||||
try {
|
||||
const resources = [];
|
||||
for (const entry of closure.resources) {
|
||||
|
||||
@@ -73,7 +73,7 @@ const main = async () => {
|
||||
"--dir",
|
||||
...(args[1] !== "restore" ? ["--locations"] : []),
|
||||
...(args[1] === "checkout" ? ["--repository-prefix"] : []),
|
||||
...(args[1] === "develop" ? ["--cache"] : []),
|
||||
...(args[1] === "develop" ? ["--cache", "--workspace-id"] : []),
|
||||
...(args[1] === "backup" ? ["--output"] : []),
|
||||
].includes(args[i]) ||
|
||||
!args[i + 1] ||
|
||||
@@ -100,7 +100,11 @@ const main = async () => {
|
||||
if (args[1] === "develop") {
|
||||
if (!flags.get("--cache")) throw Error("source develop requires --cache DIRECTORY");
|
||||
const { prepareDevelopmentSources } = await import("./development-sources.js");
|
||||
result = await prepareDevelopmentSources({ ...options, cacheDirectory: path.resolve(flags.get("--cache")!) });
|
||||
result = await prepareDevelopmentSources({
|
||||
...options,
|
||||
cacheDirectory: path.resolve(flags.get("--cache")!),
|
||||
...(flags.has("--workspace-id") ? { workspaceId: flags.get("--workspace-id")! } : {}),
|
||||
});
|
||||
} else if (args[1] === "backup") {
|
||||
if (!flags.get("--output")) throw Error("source backup requires --output DIRECTORY");
|
||||
const { backupWorkspaceSources } = await import("./source-backup.js");
|
||||
|
||||
Reference in New Issue
Block a user