Make Project Management a native feature
- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
This commit is contained in:
@@ -6,6 +6,7 @@ import { storedSwitches, switchesFrom } from "../../../src/lib/features/state.ts
|
||||
import { legacySwitch, migrateFeatures, type LegacyPlugin } from "../../../src/lib/features/migration.ts";
|
||||
import type { BackgroundMigrationHost, BackgroundSettings } from "../../../src/lib/features/backgroundSettings.ts";
|
||||
import type { TerminalMigrationHost } from "../../../src/lib/features/terminalSettings.ts";
|
||||
import type { ProjectManagementMigrationHost } from "../../../src/lib/features/pmSettings.ts";
|
||||
import { featureErrors, featureRequested, loadFeature } from "../../../src/lib/features/loader.ts";
|
||||
import { FeatureSession } from "../../../src/lib/features/session.ts";
|
||||
import type { FeatureContext, FeatureInstance, FeatureModule } from "../../../src/lib/features/types.ts";
|
||||
@@ -33,9 +34,9 @@ test("switches keep known booleans only, and missing keys take the default", ()
|
||||
assert.deepEqual(storedSwitches({ git: false, terminal: "no", csv: true, other: "yes" }), { git: false });
|
||||
assert.deepEqual(storedSwitches(null), {});
|
||||
assert.deepEqual(storedSwitches(["git"]), {});
|
||||
assert.deepEqual(switchesFrom(undefined), { git: true, background: true, terminal: true, pdf: true });
|
||||
assert.deepEqual(switchesFrom({ git: false, background: false, terminal: false, pdf: false }), { git: false, background: false, terminal: false, pdf: false });
|
||||
assert.deepEqual(switchesFrom({ git: "false" }), { git: true, background: true, terminal: true, pdf: true });
|
||||
assert.deepEqual(switchesFrom(undefined), { git: true, background: true, terminal: true, pdf: true, pm: true });
|
||||
assert.deepEqual(switchesFrom({ git: false, background: false, terminal: false, pdf: false, pm: false }), { git: false, background: false, terminal: false, pdf: false, pm: false });
|
||||
assert.deepEqual(switchesFrom({ git: "false" }), { git: true, background: true, terminal: true, pdf: true, pm: true });
|
||||
});
|
||||
|
||||
test("an installed package gives its state, and without a package the default applies", () => {
|
||||
@@ -63,6 +64,11 @@ function presentTerminal(): TerminalMigrationHost {
|
||||
return { missing: () => false, legacy: () => { throw new Error("not asked"); }, write: async () => { throw new Error("not asked"); } };
|
||||
}
|
||||
|
||||
/** A Project Management host with a section already present. */
|
||||
function presentProjectManagement(): ProjectManagementMigrationHost {
|
||||
return { missing: () => false, write: async () => { throw new Error("not asked"); }, storage: { getItem: () => { throw new Error("not asked"); }, setItem: () => { throw new Error("not asked"); } } };
|
||||
}
|
||||
|
||||
test("the migration asks only for features without a switch, and keeps other keys", async () => {
|
||||
const writes: unknown[] = [];
|
||||
const asked: string[][] = [];
|
||||
@@ -71,10 +77,10 @@ test("the migration asks only for features without a switch, and keeps other key
|
||||
write: async (value: unknown) => { writes.push(value); },
|
||||
legacy: async (ids: string[]) => { asked.push(ids); return packages; },
|
||||
});
|
||||
assert.deepEqual(await migrateFeatures(host({ future: 1, background: false, terminal: true, pdf: true }, [{ id: "runestone.git", installed: true, enabled: false, settings: null }]), presentBackground(), presentTerminal()), ["git"]);
|
||||
assert.deepEqual(await migrateFeatures(host({ future: 1, background: false, terminal: true, pdf: true, pm: true }, [{ id: "runestone.git", installed: true, enabled: false, settings: null }]), presentBackground(), presentTerminal(), presentProjectManagement()), ["git"]);
|
||||
assert.deepEqual(asked, [["runestone.git"]]);
|
||||
assert.deepEqual(writes, [{ future: 1, background: false, terminal: true, pdf: true, git: false }]);
|
||||
assert.deepEqual(await migrateFeatures(host({ git: true, background: true, terminal: true, pdf: true }, []), presentBackground(), presentTerminal()), []);
|
||||
assert.deepEqual(writes, [{ future: 1, background: false, terminal: true, pdf: true, pm: true, git: false }]);
|
||||
assert.deepEqual(await migrateFeatures(host({ git: true, background: true, terminal: true, pdf: true, pm: true }, []), presentBackground(), presentTerminal(), presentProjectManagement()), []);
|
||||
assert.equal(asked.length, 1, "A stored switch needs no package read.");
|
||||
assert.equal(writes.length, 1);
|
||||
});
|
||||
@@ -84,17 +90,17 @@ test("a missing background section asks for the slideshow package and makes the
|
||||
const switches: unknown[] = [];
|
||||
const sections: BackgroundSettings[] = [];
|
||||
const background: BackgroundMigrationHost = { missing: () => true, hasImage: () => true, migrateFolder: async () => true, write: async value => { sections.push(value); } };
|
||||
const host = { read: () => ({ git: true, background: false, terminal: true, pdf: true }), write: async (value: unknown) => { switches.push(value); }, legacy: async (ids: string[]) => { asked.push(ids); return []; } };
|
||||
assert.deepEqual(await migrateFeatures(host, background, presentTerminal()), []);
|
||||
const host = { read: () => ({ git: true, background: false, terminal: true, pdf: true, pm: true }), write: async (value: unknown) => { switches.push(value); }, legacy: async (ids: string[]) => { asked.push(ids); return []; } };
|
||||
assert.deepEqual(await migrateFeatures(host, background, presentTerminal(), presentProjectManagement()), []);
|
||||
assert.deepEqual(asked, [["runestone.bg-slideshow"]]);
|
||||
assert.deepEqual(switches, [], "Stored switches stay.");
|
||||
assert.equal(sections.length, 1);
|
||||
assert.equal(sections[0].source, "image");
|
||||
// Both migrations together ask once for both packages.
|
||||
asked.length = 0;
|
||||
await migrateFeatures({ ...host, read: () => undefined }, background, presentTerminal());
|
||||
assert.deepEqual(asked, [["runestone.git", "runestone.bg-slideshow", "runestone.terminal", "runestone.pdf-viewer"]]);
|
||||
assert.deepEqual(switches, [{ git: true, background: true, terminal: true, pdf: true }]);
|
||||
await migrateFeatures({ ...host, read: () => undefined }, background, presentTerminal(), presentProjectManagement());
|
||||
assert.deepEqual(asked, [["runestone.git", "runestone.bg-slideshow", "runestone.terminal", "runestone.pdf-viewer", "runestone.pm"]]);
|
||||
assert.deepEqual(switches, [{ git: true, background: true, terminal: true, pdf: true, pm: true }]);
|
||||
});
|
||||
|
||||
test("a failed package read writes nothing, so the next start tries again", async () => {
|
||||
@@ -103,7 +109,7 @@ test("a failed package read writes nothing, so the next start tries again", asyn
|
||||
console.error = () => {};
|
||||
try {
|
||||
const background: BackgroundMigrationHost = { missing: () => true, hasImage: () => true, migrateFolder: async () => true, write: async value => { writes.push(value); } };
|
||||
const result = await migrateFeatures({ read: () => undefined, write: async value => { writes.push(value); }, legacy: async () => { throw new Error("no host"); } }, background, presentTerminal());
|
||||
const result = await migrateFeatures({ read: () => undefined, write: async value => { writes.push(value); }, legacy: async () => { throw new Error("no host"); } }, background, presentTerminal(), presentProjectManagement());
|
||||
assert.deepEqual(result, []);
|
||||
assert.deepEqual(writes, []);
|
||||
} finally { console.error = error; }
|
||||
@@ -125,7 +131,7 @@ test("the loader imports a feature one time, reports a failure, and tries again
|
||||
});
|
||||
|
||||
function fakeContext(opened: string[] = []): FeatureContext {
|
||||
return { openView: id => { opened.push(id); }, openFile: async () => {}, onWorkspaceChange: () => () => {} };
|
||||
return { openView: id => { opened.push(id); }, openFile: async () => {}, onWorkspaceChange: () => () => {}, setViewTitle: () => {}, closeView: () => {}, replaceView: () => {} };
|
||||
}
|
||||
|
||||
test("a feature session shows its views and commands without loading the feature", async () => {
|
||||
|
||||
Reference in New Issue
Block a user