@mccaskie-labs/workbench-ui 0.4.0 → 0.4.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/CHANGELOG.md +6 -0
- package/dist/cli.js +16 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.d.ts +6 -5
- package/dist/styles.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-ui
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `npx workbench-ui styles` finds every `@mccaskie-labs/workbench-*` package the project depends on whose package.json exports `./styles`, so a new tool's classes join workbench.css without a workbench-ui release (workbench-pdf 0.2.0 and workbench-email 0.3.0 are the next). `STYLED_PACKAGES` is replaced by `STYLED_SCOPE`.
|
|
8
|
+
|
|
3
9
|
## 0.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from
|
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { dirname, join, resolve } from "node:path";
|
|
20
20
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
21
|
-
import { renderStyles, STYLE_FILES,
|
|
21
|
+
import { renderStyles, STYLE_FILES, STYLED_SCOPE, starterProjectCss, unknownNames } from "./styles.js";
|
|
22
22
|
const USAGE = "usage: workbench-ui styles [--check] [dir]";
|
|
23
23
|
const read = (path) => readFileSync(path, "utf8").replace(/\r\n/g, "\n");
|
|
24
24
|
/** The styles of each Workbench tool the project at `dir` has installed, and the workbench-ui version. */
|
|
@@ -32,23 +32,23 @@ export async function installedStyles(dir) {
|
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
+
// Every Workbench package the project depends on whose package.json exports "./styles".
|
|
36
|
+
const project = JSON.parse(read(join(dir, "package.json")));
|
|
37
|
+
const names = [...new Set([...Object.keys(project.dependencies ?? {}), ...Object.keys(project.devDependencies ?? {})])].filter((n) => n.startsWith(STYLED_SCOPE)).sort();
|
|
35
38
|
const tools = [];
|
|
36
|
-
for (const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
// Found by folder, not through its exports, which needn't list ./package.json.
|
|
41
|
+
const at = (req.resolve.paths(name) ?? []).map((d) => join(d, name, "package.json")).find((f) => existsSync(f));
|
|
42
|
+
if (!at)
|
|
43
|
+
throw new Error(`${name} isn't installed: run npm install`);
|
|
44
|
+
const manifest = JSON.parse(read(at));
|
|
45
|
+
if (!manifest.exports || !Object.hasOwn(manifest.exports, "./styles"))
|
|
39
46
|
continue;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new Error(`${p.package} ${v} has no ./styles export: update it to a version that has one`);
|
|
46
|
-
}
|
|
47
|
-
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(path).href)));
|
|
48
|
-
const styles = mod[p.export];
|
|
49
|
-
if (!styles)
|
|
50
|
-
throw new Error(`${p.package}/styles doesn't export ${p.export}`);
|
|
51
|
-
tools.push({ styles, version: v });
|
|
47
|
+
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(req.resolve(`${name}/styles`)).href)));
|
|
48
|
+
const found = Object.values(mod).filter((x) => !!x && typeof x === "object" && x.format === 1 && typeof x.prefix === "string");
|
|
49
|
+
if (found.length !== 1)
|
|
50
|
+
throw new Error(`${name}/styles must export exactly one ToolStyles`);
|
|
51
|
+
tools.push({ styles: found[0], version: manifest.version });
|
|
52
52
|
}
|
|
53
53
|
const own = JSON.parse(read(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json")));
|
|
54
54
|
return { tools, uiVersion: version("@mccaskie-labs/workbench-ui") ?? own.version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CSS, STYLE } from "./style.ts";
|
|
2
2
|
export { FORM_SCRIPT } from "./form-script.ts";
|
|
3
|
-
export { renderStyles, STYLE_FILES,
|
|
3
|
+
export { renderStyles, STYLE_FILES, STYLED_SCOPE, styleNames, styleProblems, STYLESHEETS, starterProjectCss, unknownNames, type InstalledStyles, type StyleClass, type StyleState, type StyleVariable, type ToolStyles, } from "./styles.ts";
|
|
4
4
|
/** Plain text made safe to put in HTML, in text or in a quoted attribute. */
|
|
5
5
|
export declare const escape: (value: string) => string;
|
|
6
6
|
/** The outcome colours: a pill's class and, prefixed with o-, a table row's left edge. */
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { STYLE } from "./style.js";
|
|
6
6
|
export { CSS, STYLE } from "./style.js";
|
|
7
7
|
export { FORM_SCRIPT } from "./form-script.js";
|
|
8
|
-
export { renderStyles, STYLE_FILES,
|
|
8
|
+
export { renderStyles, STYLE_FILES, STYLED_SCOPE, styleNames, styleProblems, STYLESHEETS, starterProjectCss, unknownNames, } from "./styles.js";
|
|
9
9
|
/** Plain text made safe to put in HTML, in text or in a quoted attribute. */
|
|
10
10
|
export const escape = (value) => value.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
11
11
|
/** A coloured outcome pill. `text` is plain text. */
|
package/dist/styles.d.ts
CHANGED
|
@@ -40,11 +40,12 @@ export declare const STYLE_FILES: {
|
|
|
40
40
|
};
|
|
41
41
|
/** The addresses a page links, in order: Workbench's defaults, then the project's own rules. */
|
|
42
42
|
export declare const STYLESHEETS: readonly string[];
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The scope searched for tools that draw on a project's pages: every package
|
|
45
|
+
* the project depends on in it whose package.json exports "./styles", which
|
|
46
|
+
* exports one ToolStyles (workbench-forms' FORM_STYLES, workbench-pdf's PDF_STYLES).
|
|
47
|
+
*/
|
|
48
|
+
export declare const STYLED_SCOPE = "@mccaskie-labs/workbench-";
|
|
48
49
|
/** What is wrong with a tool's styles: a name off its prefix, a class with no default rule, a variable used but not listed. */
|
|
49
50
|
export declare function styleProblems(s: ToolStyles): string[];
|
|
50
51
|
/**
|
package/dist/styles.js
CHANGED
|
@@ -11,8 +11,12 @@ import { CSS } from "./style.js";
|
|
|
11
11
|
export const STYLE_FILES = { generated: "public/styles/workbench.css", project: "public/styles/project.css" };
|
|
12
12
|
/** The addresses a page links, in order: Workbench's defaults, then the project's own rules. */
|
|
13
13
|
export const STYLESHEETS = ["/styles/workbench.css", "/styles/project.css"];
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The scope searched for tools that draw on a project's pages: every package
|
|
16
|
+
* the project depends on in it whose package.json exports "./styles", which
|
|
17
|
+
* exports one ToolStyles (workbench-forms' FORM_STYLES, workbench-pdf's PDF_STYLES).
|
|
18
|
+
*/
|
|
19
|
+
export const STYLED_SCOPE = "@mccaskie-labs/workbench-";
|
|
16
20
|
const NAME = /^[a-z][a-z0-9-]*$/;
|
|
17
21
|
/** What is wrong with a tool's styles: a name off its prefix, a class with no default rule, a variable used but not listed. */
|
|
18
22
|
export function styleProblems(s) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Workbench pages: one dark look, a top bar with the environment tag, cards, outcome pills, and one format for times, money and durations.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|