@smallpen/cli 0.1.0-alpha.18 → 0.1.0-alpha.19
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/bin/command-contract.mjs +1 -1
- package/bin/schema.mjs +2 -2
- package/bin/smallpen.mjs +13 -8
- package/package.json +3 -3
package/bin/command-contract.mjs
CHANGED
|
@@ -165,7 +165,7 @@ const PARAMETERS = {
|
|
|
165
165
|
setField: parameter(
|
|
166
166
|
"--set",
|
|
167
167
|
"assignment",
|
|
168
|
-
'FIELD=VALUE as in page draw: width=320, fill={color.surface}, padding=[8,16], text="Save", props={"Style":"ghost"}; a JSON value or plain text',
|
|
168
|
+
'FIELD=VALUE as in page draw: width=320, fill={color.surface}, padding=[8,16], text="Save", props={"Style":"ghost"}; a JSON value or plain text. Conflicting values for one field, including --intent values, are rejected',
|
|
169
169
|
{ repeatable: true },
|
|
170
170
|
),
|
|
171
171
|
variant: parameter("--variant", "string", 'One variant, as "Style=secondary" (or just "secondary")'),
|
package/bin/schema.mjs
CHANGED
|
@@ -762,8 +762,8 @@ function setTopic(command) {
|
|
|
762
762
|
return {
|
|
763
763
|
command,
|
|
764
764
|
fields: {
|
|
765
|
-
set: "FIELD=VALUE, repeatable; VALUE is JSON (320, [8,16], {\"Style\":\"ghost\"}, true) or plain text; {token.path} binds a Token",
|
|
766
|
-
element: "fields: width, height (number, px, Token, fill, hug), fill, stroke, radius, opacity, shadow, visible, rotation, margin, min/max sizes; texts: text, color, font, fontFamily, fontSize, fontWeight, lineHeight, letterSpacing, textTransform, textDecoration, textAlign; containers: layout (row|column|none), gap, padding, align, justify",
|
|
765
|
+
set: "FIELD=VALUE, repeatable; VALUE is JSON (320, [8,16], {\"Style\":\"ghost\"}, true) or plain text; {token.path} binds a Token. Conflicting values for one field, including --intent values, are rejected",
|
|
766
|
+
element: "fields: width, height (number, px, Token, fill, hug), fill, stroke, radius, opacity, shadow, visible, rotation, margin, min/max sizes; texts: text, color, font, fontFamily, fontSize, fontWeight, lineHeight, letterSpacing, textTransform, textDecoration, textAlign; containers: layout (row|column|none), gap, padding, align (start|center|end|stretch), justify (start|center|end|space-between). gap, padding, align and justify need a row or column on the target",
|
|
767
767
|
copy: "a copy of a component: props, text {\"Element\": \"text\"}, set {\"Element.field\": value}, width/height (numbers, px, Tokens, hug, or fill in a row/column parent), visible, opacity. Sizes inside set (Element.width/height) take numbers or Tokens",
|
|
768
768
|
itself: "without --element: the page version (or the variant) itself, for example its width and height",
|
|
769
769
|
},
|
package/bin/smallpen.mjs
CHANGED
|
@@ -1258,11 +1258,11 @@ async function writeReply(result, args) {
|
|
|
1258
1258
|
const files =
|
|
1259
1259
|
(result.changedFiles?.length ?? 0) + (result.deletedFiles?.length ?? 0);
|
|
1260
1260
|
const warnings = result.warningSummary?.total ?? result.warnings?.length ?? 0;
|
|
1261
|
-
const verb = result.
|
|
1262
|
-
? "
|
|
1263
|
-
: result.
|
|
1264
|
-
? "
|
|
1265
|
-
: "Applied";
|
|
1261
|
+
const verb = result.alreadyApplied
|
|
1262
|
+
? "Already applied"
|
|
1263
|
+
: result.changed === false
|
|
1264
|
+
? result.dryRun ? "No changes (preview)" : "No changes"
|
|
1265
|
+
: result.dryRun ? "Previewed" : "Applied";
|
|
1266
1266
|
// Empty advice says nothing: leave it out of the short reply.
|
|
1267
1267
|
if (!rest.reuseReminders?.length) delete rest.reuseReminders;
|
|
1268
1268
|
if (!rest.reuseSummary?.total) delete rest.reuseSummary;
|
|
@@ -3734,12 +3734,12 @@ async function namedContextArgs(packagePath, args) {
|
|
|
3734
3734
|
}
|
|
3735
3735
|
|
|
3736
3736
|
// page set / component set: the target by name, the fields from --set
|
|
3737
|
-
// FIELD=VALUE (a JSON value, else text)
|
|
3737
|
+
// FIELD=VALUE (a JSON value, else text) alongside --intent {"set": {...}}.
|
|
3738
3738
|
async function setIntent(command, args) {
|
|
3739
3739
|
const file = option(args, "--intent");
|
|
3740
3740
|
const base = file ? parseJson(await readInputFile(file, "--intent", "utf8"), `invalid_${command.replace("-", "_")}_json`) : {};
|
|
3741
3741
|
if (!isRecord(base)) throw new SmallPenError("invalid_set", "--intent holds {\"set\": {...}}");
|
|
3742
|
-
const set =
|
|
3742
|
+
const set = Object.assign(Object.create(null), isRecord(base.set) ? base.set : {});
|
|
3743
3743
|
for (const assignment of options(args, "--set")) {
|
|
3744
3744
|
const at = assignment.indexOf("=");
|
|
3745
3745
|
if (at <= 0) throw new SmallPenError("invalid_set", `--set takes FIELD=VALUE, not ${assignment}`);
|
|
@@ -3752,7 +3752,12 @@ async function setIntent(command, args) {
|
|
|
3752
3752
|
} catch {
|
|
3753
3753
|
value = raw;
|
|
3754
3754
|
}
|
|
3755
|
-
|
|
3755
|
+
const field = assignment.slice(0, at).trim();
|
|
3756
|
+
if (Object.hasOwn(set, field) && canonicalJSON(set[field]) !== canonicalJSON(value))
|
|
3757
|
+
throw new SmallPenError("conflicting_set_field", `Conflicting values for ${field}; give this field one value`, {
|
|
3758
|
+
field, previous: set[field], received: value,
|
|
3759
|
+
});
|
|
3760
|
+
set[field] = value;
|
|
3756
3761
|
}
|
|
3757
3762
|
const target = command === "page-set"
|
|
3758
3763
|
? { page: option(args, "--page") ?? base.page, platform: option(args, "--platform") ?? base.platform }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smallpen/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.19",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"bin"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@smallpen/core": "0.1.0-alpha.
|
|
19
|
-
"@smallpen/local-package": "0.1.0-alpha.
|
|
18
|
+
"@smallpen/core": "0.1.0-alpha.19",
|
|
19
|
+
"@smallpen/local-package": "0.1.0-alpha.19"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|