tessello 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +10 -2
- package/cli.js +45 -0
- package/package.json +20 -4
- package/validate-command.js +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 craftskillz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tessello
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Tessello command-line tool.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx tessello validate my-module # a Module folder
|
|
7
|
+
npx tessello validate my-module.zip # or its .zip
|
|
8
|
+
npx tessello validate my-module --json # the report as JSON
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
It checks the Module against the Tessello [Convention](https://github.com/craftskillz/tessello/blob/main/convention/CONVENTION.md) and exits with 1 when the Module is not installable, 0 otherwise. Every error and warning names the file and says what to change: fix them until there is no error left, then zip the *contents* of the folder (not the folder itself).
|
package/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { formatReport, validatePath } from "./validate-command.js";
|
|
5
|
+
const USAGE = `Usage: tessello <command>
|
|
6
|
+
|
|
7
|
+
Commands:
|
|
8
|
+
validate <path> [--json] Check a Module folder or .zip against the Tessello Convention.
|
|
9
|
+
Exits with 1 if the Module is not installable.`;
|
|
10
|
+
/** Runs the CLI and returns the process exit code: 0 success, 1 invalid Module, 2 usage error. */
|
|
11
|
+
export async function run(args, output) {
|
|
12
|
+
const [command, ...rest] = args;
|
|
13
|
+
if (command === "validate") {
|
|
14
|
+
const json = rest.includes("--json");
|
|
15
|
+
const paths = rest.filter((arg) => arg !== "--json");
|
|
16
|
+
if (paths.length !== 1) {
|
|
17
|
+
output.err(USAGE);
|
|
18
|
+
return 2;
|
|
19
|
+
}
|
|
20
|
+
const target = paths[0];
|
|
21
|
+
let report;
|
|
22
|
+
try {
|
|
23
|
+
report = await validatePath(target);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
output.err(`Cannot read "${target}": ${e.message}`);
|
|
27
|
+
return 2;
|
|
28
|
+
}
|
|
29
|
+
output.out(json ? JSON.stringify(report, null, 2) : formatReport(target, report));
|
|
30
|
+
return report.valid ? 0 : 1;
|
|
31
|
+
}
|
|
32
|
+
if (command === undefined || command === "help" || command === "--help" || command === "-h") {
|
|
33
|
+
output.out(USAGE);
|
|
34
|
+
return command === undefined ? 2 : 0;
|
|
35
|
+
}
|
|
36
|
+
output.err(`Unknown command "${command}".\n\n${USAGE}`);
|
|
37
|
+
return 2;
|
|
38
|
+
}
|
|
39
|
+
// npm runs the CLI through a symbolic link (node_modules/.bin/tessello), hence the real path.
|
|
40
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
41
|
+
process.exitCode = await run(process.argv.slice(2), {
|
|
42
|
+
out: (text) => console.log(text),
|
|
43
|
+
err: (text) => console.error(text),
|
|
44
|
+
});
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tessello",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tessello command-line tool.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@tessello/convention": "0.1.0"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"tessello": "./cli.js"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/craftskillz/tessello.git",
|
|
16
|
+
"directory": "packages/cli"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/craftskillz/tessello#readme",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22.12"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { join, relative, sep } from "node:path";
|
|
3
|
+
import { validatePackage, validateZip } from "@tessello/convention";
|
|
4
|
+
// Files a Creator's folder may contain that are never part of a package.
|
|
5
|
+
const IGNORED_NAMES = new Set([".DS_Store", ".git"]);
|
|
6
|
+
/** Validates a Module folder or .zip archive on disk. */
|
|
7
|
+
export async function validatePath(path) {
|
|
8
|
+
const info = await stat(path);
|
|
9
|
+
if (info.isDirectory())
|
|
10
|
+
return validatePackage(await readFolder(path));
|
|
11
|
+
return validateZip(new Uint8Array(await readFile(path)));
|
|
12
|
+
}
|
|
13
|
+
async function readFolder(root) {
|
|
14
|
+
const files = new Map();
|
|
15
|
+
const entries = await readdir(root, { recursive: true, withFileTypes: true });
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
if (!entry.isFile())
|
|
18
|
+
continue;
|
|
19
|
+
const absolute = join(entry.parentPath, entry.name);
|
|
20
|
+
const path = relative(root, absolute).split(sep).join("/");
|
|
21
|
+
if (path.split("/").some((part) => IGNORED_NAMES.has(part)))
|
|
22
|
+
continue;
|
|
23
|
+
files.set(path, new Uint8Array(await readFile(absolute)));
|
|
24
|
+
}
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
/** Human-readable report, meant to be read by Creators and by LLMs fixing their Module. */
|
|
28
|
+
export function formatReport(target, report) {
|
|
29
|
+
const lines = [];
|
|
30
|
+
const identity = report.manifest ? ` (${report.manifest.id} ${report.manifest.version})` : "";
|
|
31
|
+
lines.push(`Validating ${target}${identity}`);
|
|
32
|
+
const errors = report.issues.filter((issue) => issue.severity === "error");
|
|
33
|
+
const warnings = report.issues.filter((issue) => issue.severity === "warning");
|
|
34
|
+
for (const issue of [...errors, ...warnings])
|
|
35
|
+
lines.push(formatIssue(issue));
|
|
36
|
+
const count = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
37
|
+
lines.push(report.valid
|
|
38
|
+
? `✓ ${count(warnings.length, "warning")}: this Module is installable.`
|
|
39
|
+
: `${count(errors.length, "error")}, ${count(warnings.length, "warning")}: this Module is not installable.`);
|
|
40
|
+
return lines.join("\n");
|
|
41
|
+
}
|
|
42
|
+
function formatIssue(issue) {
|
|
43
|
+
const mark = issue.severity === "error" ? "✗" : "⚠";
|
|
44
|
+
return `${mark} ${issue.message} [${issue.code}]`;
|
|
45
|
+
}
|