walover-line-harness-gui 0.2.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "walover-line-harness-gui",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "LINE Harness のセットアップを、ターミナルを開かずにブラウザから行うためのローカルツール",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,8 +6,12 @@
6
6
  * そのため**動作確認済みの版を固定して呼ぶ**。
7
7
  *
8
8
  * ただし固定したまま黙っていると、本家の修正に永久に追いつかない。
9
- * 起動時に npm の `latest` と比べ、差があれば**警告だけ**出す。
10
- * 自動では追従しない。追従には契約の再照合(`npm run check:contract`)が要る。
9
+ * 起動時に npm の `latest` と比べ、差があれば知らせる。自動では追従しない。
10
+ * 追従には契約の再照合(`npm run check:contract`)が要る。
11
+ *
12
+ * **強さを取り違えない。** 新しい版が出ているだけなら参加者はこのまま進めてよく、
13
+ * 警告として出すと進めてよいのに手が止まる。一方、固定版が npm で見つからないのは
14
+ * 人が確かめる必要がある。この区別を {@link VersionNotice} の tone で表す。
11
15
  *
12
16
  * > npm パッケージ(`create-line-harness`)とアプリ本体(`line-oss-crm`)は
13
17
  * > バージョンが別で、プロンプトは npm パッケージ側にある。
@@ -64,7 +68,23 @@ export async function resolveVersion(spec = "latest", options = {}) {
64
68
  * @property {string} pinned 固定している版
65
69
  * @property {string|null} latest npm の最新版。取れなければ null
66
70
  * @property {"pinned-is-latest"|"newer-available"|"pinned-is-newer"|"unknown"} status
67
- * @property {string|null} warning 画面に出す文言
71
+ * @property {VersionNotice|null} notice 画面に出すもの
72
+ * @property {string|null} warning ターミナルに出す平文(notice から作る)
73
+ */
74
+
75
+ /**
76
+ * 画面に出すときの中身。
77
+ *
78
+ * **読者は非開発者の勉強会参加者。** 版が古いこと自体は参加者の関心事ではなく、
79
+ * 知りたいのは「自分はこのまま進めてよいのか」だけ。
80
+ * headline はその答えを先に書き、版番号のような事情は detail に送る。
81
+ *
82
+ * tone は強さ。`info` は畳んで出してよいもの、`warn` は人の判断が要るもの。
83
+ *
84
+ * @typedef {object} VersionNotice
85
+ * @property {"info"|"warn"} tone
86
+ * @property {string} headline 参加者が最初に読む一文
87
+ * @property {string} detail 事情の説明。畳んだ中に置く
68
88
  */
69
89
 
70
90
  /**
@@ -84,6 +104,7 @@ export async function checkCliVersion(options = {}) {
84
104
  pinned,
85
105
  latest: null,
86
106
  status: "unknown",
107
+ notice: null,
87
108
  warning: null,
88
109
  };
89
110
  }
@@ -91,31 +112,45 @@ export async function checkCliVersion(options = {}) {
91
112
  const order = compareVersions(pinned, latest);
92
113
 
93
114
  if (order === 0) {
94
- return { pinned, latest, status: "pinned-is-latest", warning: null };
115
+ return { pinned, latest, status: "pinned-is-latest", notice: null, warning: null };
95
116
  }
96
117
 
97
118
  if (order < 0) {
98
- return {
119
+ // 新しい版が出ているだけ。**参加者はこのまま進めてよい。**
120
+ // ここを警告として強く出すと、進めてよいのに手が止まる
121
+ return withWarning({
99
122
  pinned,
100
123
  latest,
101
124
  status: "newer-available",
102
- warning: [
103
- `本家 CLI の新しい版 v${latest} が出ています(このツールが確認済みなのは v${pinned})。`,
104
- "動作未確認のため、追従には検証が必要です。このままでも v" + pinned + " でセットアップできます。",
105
- ].join("\n"),
106
- };
125
+ notice: {
126
+ tone: "info",
127
+ headline: `このまま進めて構いません。動作確認済みの v${pinned} でセットアップします。`,
128
+ detail:
129
+ `本家 CLI の新しい版 v${latest} が出ています(このツールが確認済みなのは v${pinned})。` +
130
+ "追従にはプロンプト契約の再照合と検証が要るため、自動では追いかけません。",
131
+ },
132
+ });
107
133
  }
108
134
 
109
- // 固定版のほうが新しい。npm 側が取り下げられた場合などに起きる
110
- return {
135
+ // 固定版のほうが新しい。npm 側が取り下げられた場合などに起きる。
136
+ // これは**人が確かめる必要がある**ので、弱めない
137
+ return withWarning({
111
138
  pinned,
112
139
  latest,
113
140
  status: "pinned-is-newer",
114
- warning: [
115
- `固定している v${pinned} が npm の最新 v${latest} より新しくなっています。`,
116
- "npm 側で取り下げられた可能性があります。動作未確認のため、確認が必要です。",
117
- ].join("\n"),
118
- };
141
+ notice: {
142
+ tone: "warn",
143
+ headline: "固定している版が npm で見つかりません。開発者に連絡してください。",
144
+ detail:
145
+ `固定している v${pinned} が npm の最新 v${latest} より新しくなっています。` +
146
+ "npm 側で取り下げられた可能性があります。動作未確認のため、確認が必要です。",
147
+ },
148
+ });
149
+ }
150
+
151
+ /** ターミナル用の平文。画面と同じ内容を1つの文字列にする */
152
+ function withWarning(status) {
153
+ return { ...status, warning: `${status.notice.headline}\n${status.notice.detail}` };
119
154
  }
120
155
 
121
156
  /** @type {Promise<VersionStatus>|null} */
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  /** 契約が対象とする本家 CLI のバージョン。ズレの検知は #5 で行う */
26
- export const CONTRACT_CLI_VERSION = "0.2.11";
26
+ export const CONTRACT_CLI_VERSION = "0.2.12";
27
27
 
28
28
  /**
29
29
  * @typedef {object} PromptSpec
@@ -133,7 +133,9 @@ export const PROMPTS = [
133
133
  id: "lineChannelSecret",
134
134
  message: "チャネルシークレット(英数字)",
135
135
  kind: "text",
136
- placeholder: "同じページに表示されている Channel Secret",
136
+ // 0.2.12 で本家が p.text → p.password にした。値行は伏字(▪)になり、
137
+ // placeholder は無くなった。宣言したままだと第二の照合が外れて止まる。
138
+ // message が一意なので、外しても取り違えは起きない
137
139
  secret: true,
138
140
  answer: "form",
139
141
  field: "lineChannelSecret",
@@ -148,7 +150,7 @@ export const PROMPTS = [
148
150
  id: "lineChannelAccessToken",
149
151
  message: "チャネルアクセストークン(長期)",
150
152
  kind: "text",
151
- placeholder: "上の手順で発行したトークン",
153
+ // 同上。0.2.12 で p.password になった
152
154
  secret: true,
153
155
  answer: "form",
154
156
  field: "lineChannelAccessToken",
@@ -63,6 +63,16 @@
63
63
  .banner.bad { border-color: var(--err-line); background: var(--err-bg); color: var(--err); }
64
64
  .banner strong { display: block; }
65
65
 
66
+ /*
67
+ * 版のズレのように「知らせるが、進めてよい」もの。
68
+ * 警告(.banner)と同じ強さで出すと、進めてよいのに手が止まる
69
+ */
70
+ .note { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
71
+ .note > summary { cursor: pointer; list-style-position: inside; }
72
+ .note > summary::marker { color: var(--muted); }
73
+ .note .note-detail { margin: .4rem 0 0 1.1rem; padding-left: .7rem;
74
+ border-left: 2px solid var(--line); white-space: pre-line; }
75
+
66
76
  .status { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted);
67
77
  margin-bottom: 1.5rem; }
68
78
  .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); flex: none; }
@@ -285,10 +295,21 @@
285
295
  );
286
296
  }
287
297
 
288
- // 本家 CLI の版のズレ(固定版で動かすので、差があっても止めずに知らせるだけ)
298
+ // 本家 CLI の版のズレ。
299
+ //
300
+ // 固定版で動かすので、新しい版が出ているだけなら**参加者はこのまま進めてよい**。
301
+ // そこを警告として強く出すと、進めてよいのに手が止まる(実機で起きた)。
302
+ // 強さはサーバーが tone で決める。ここはそれに従って出し分けるだけ
289
303
  try {
290
304
  const version = await (await fetch("/api/version")).json();
291
- if (version.warning) banner("本家 CLI のバージョン", version.warning);
305
+ if (version.notice?.tone === "warn") {
306
+ banner(version.notice.headline, version.notice.detail, true);
307
+ } else if (version.notice) {
308
+ const box = el("details", { className: "note" });
309
+ box.append(el("summary", { textContent: version.notice.headline }));
310
+ box.append(el("p", { className: "note-detail", textContent: version.notice.detail }));
311
+ $("banners").append(box);
312
+ }
292
313
  } catch {
293
314
  /* 版が確認できなくても入力は進められる */
294
315
  }