fa-mcp-sdk 0.4.79 → 0.4.84

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/fa-mcp.js CHANGED
@@ -984,7 +984,8 @@ certificate's public and private keys`,
984
984
  const scriptsTargetPath = path.join(targetPath, 'scripts');
985
985
  await this.copyDirectory(path.join(PROJ_ROOT, 'scripts'), scriptsTargetPath);
986
986
  await fs.rm(path.join(targetPath, 'scripts/copy-static.js'), { force: true });
987
- await fs.rm(path.join(targetPath, 'scripts/publish.sh'), { force: true });
987
+ await fs.rm(path.join(targetPath, 'scripts/publish.js'), { force: true });
988
+ await fs.rm(path.join(targetPath, 'scripts/publish-README.md'), { force: true });
988
989
 
989
990
  // Rename all .xml files in .run directory to .run.xml
990
991
  const runDirPath = path.join(targetPath, '.run');
@@ -260,11 +260,11 @@ For any other changed template file, the generated guide must include:
260
260
  ### 4.4 Analyze changes in scripts
261
261
 
262
262
  The CLI copies scripts from `node_modules/fa-mcp-sdk/scripts/` (NOT from `cli-template/scripts/`) into the project's
263
- `scripts/` directory, and then removes `copy-static.js` and `publish.sh` (SDK-internal, not needed in downstream projects).
263
+ `scripts/` directory, and then removes `copy-static.js`, `publish.js`, `scripts/publish-README.md` (SDK-internal, not needed in downstream projects).
264
264
 
265
265
  - Canonical source: `node_modules/fa-mcp-sdk/scripts/<name>.js`
266
266
  - Project destination: `scripts/<name>.js`
267
- - Exclude from upgrade suggestions: `copy-static.js`, `publish.sh` (SDK-only)
267
+ - Exclude from upgrade suggestions: `copy-static.js`, `publish.js`, `scripts/publish-README.md` (SDK-only)
268
268
 
269
269
  The generated guide must specify the exact source path under `node_modules/fa-mcp-sdk/scripts/...` for any script the
270
270
  user should copy into their project's `scripts/` directory, and skip the excluded SDK-only scripts.
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@modelcontextprotocol/sdk": "^1.29.0",
56
56
  "dotenv": "^17.4.1",
57
- "fa-mcp-sdk": "^0.4.79"
57
+ "fa-mcp-sdk": "^0.4.84"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/express": "^5.0.6",
@@ -39,7 +39,7 @@ Generates a migration guide for upgrading the `fa-mcp-sdk` dependency in this pr
39
39
  - `config/*.yaml` — new/removed/changed keys and defaults (correlates `default.yaml`, `_local.yaml`, `local.yaml`)
40
40
  - `cli-template/` — `package.json` (new deps only), `tsconfig.json`, `.oxlintrc.json`, `.oxfmtrc.json`, `CLAUDE.md`, `deploy/`,
41
41
  `.claude/skills/`, `.run/` (from `r/`)
42
- - `scripts/` — new or updated SDK utilities (excluding SDK-internal `copy-static.js`, `publish.sh`)
42
+ - `scripts/` — new or updated SDK utilities (excluding SDK-internal `copy-static.js`, `publish.js`, `scripts/publish-README.md`)
43
43
  - `dist/core/index.js` — added/removed/renamed exports and breaking type changes
44
44
  - project `src/` — imports and config keys affected by the upgrade
45
45
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fa-mcp-sdk",
3
3
  "productName": "FA MCP SDK",
4
- "version": "0.4.79",
4
+ "version": "0.4.84",
5
5
  "description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
6
6
  "type": "module",
7
7
  "main": "dist/core/index.js",
@@ -0,0 +1,69 @@
1
+ # scripts/publish.js
2
+
3
+ Cross-platform publish script. Bumps the patch version, commits the changes,
4
+ pushes to `master`, and runs `npm publish`.
5
+
6
+ ## Usage
7
+
8
+ ```bash
9
+ node scripts/publish.js # default: bump + commit tracked changes + push + publish
10
+ node scripts/publish.js --no-bump # publish current version as-is, no bump
11
+ node scripts/publish.js --add-all # also include untracked files in the commit
12
+ node scripts/publish.js --no-bump --add-all # combine
13
+ node scripts/publish.js --help
14
+ ```
15
+
16
+ ## Flags
17
+
18
+ | Flag | Short | Effect |
19
+ |------------------|-------|----------------------------------------------------------------------------------------|
20
+ | `--no-bump` | `-n` | Skip patch version bump. Publish the current `package.json` version as-is. |
21
+ | `--add-all` | `-a` | Stage untracked files too (`git add --all`). Default stages only tracked changes. |
22
+ | `--help` | `-h` | Show usage and exit. |
23
+
24
+ ## Workflow
25
+
26
+ 1. **Branch check** — must be on `master`. Otherwise prints a warning and exits.
27
+ 2. **Build** — runs `npm run cb` (clean + build). Aborts on failure.
28
+ 3. **Version bump** (skipped with `--no-bump`):
29
+ - Reads current version from `package.json`.
30
+ - Increments patch: `0.4.79` → `0.4.80`.
31
+ - Writes new version into `package.json` (replaces first occurrence only).
32
+ - Updates the `fa-mcp-sdk` dependency line in `cli-template/package.json` to `"^<new-version>"`.
33
+ 4. **Stage changes**:
34
+ - Default: `git add -u` — stages modifications and deletions to **tracked** files only.
35
+ - With `--add-all`: `git add --all` — also stages untracked files.
36
+ 5. **Commit + push** — if anything is staged, commits with the version string as the message
37
+ (`--no-verify`, bypasses hooks) and pushes to `origin master`. If the index is empty, both steps are skipped.
38
+ 6. **Publish** — runs `npm publish`.
39
+ 7. **Pause** — waits for Enter before exiting (matches the original bash behavior for interactive runs).
40
+
41
+ ## What gets committed (default mode)
42
+
43
+ | File state | Committed by default? | With `--add-all`? |
44
+ |----------------------------------------------------|-----------------------|-------------------|
45
+ | Bumped `package.json` (tracked + modified) | ✅ Yes | ✅ Yes |
46
+ | Bumped `cli-template/package.json` | ✅ Yes | ✅ Yes |
47
+ | Other tracked files you modified (no `git add`) | ✅ Yes | ✅ Yes |
48
+ | Tracked files you deleted (no `git add`) | ✅ Yes | ✅ Yes |
49
+ | Untracked files (new files, not in git) | ❌ No | ✅ Yes |
50
+ | Files you already `git add`-ed manually | ✅ Yes | ✅ Yes |
51
+
52
+ Rationale: `git add -u` mirrors `git commit -a` semantics — pick up edits to tracked files but never silently include
53
+ brand-new files. Use `--add-all` when you explicitly want untracked files in the release commit.
54
+
55
+ ## Edge cases
56
+
57
+ - **Wrong branch** — script exits without making any changes. No bump, no publish.
58
+ - **Build fails** — script aborts before version bump and before any git operations.
59
+ - **Nothing staged** (e.g., `--no-bump` and clean working tree) — `git commit`/`push` are skipped,
60
+ but `npm publish` still runs. Useful for re-publishing a version that was rolled back on the registry.
61
+ - **Pre-existing manual `git add`** — those files are also committed; the script does not reset the index.
62
+ - **Re-running after a failed publish** — use `--no-bump` to avoid double-incrementing the version.
63
+
64
+ ## Errors and pause behavior
65
+
66
+ On any failure (build, git, etc.) the script:
67
+ 1. Prints a red error line.
68
+ 2. Waits for Enter (so you can read the output when run via double-click in IDE/Explorer).
69
+ 3. Exits with code `0` (matches the original bash; keeps the terminal window open in interactive shells).
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Publish package to npm.
4
+ * Usage:
5
+ * node scripts/publish.js # bumps patch version, stages tracked modifications, commits, pushes, publishes
6
+ * node scripts/publish.js --no-bump # publishes current version as-is (no bump)
7
+ * node scripts/publish.js --add-all # also stages untracked files (git add --all)
8
+ * node scripts/publish.js --help
9
+ *
10
+ * Default staging behavior: `git add -u` — modified tracked files go in (incl. the bumped package.json).
11
+ * Untracked files are ignored unless --add-all is passed.
12
+ */
13
+
14
+ import { spawnSync, execSync } from 'child_process';
15
+ import { readFileSync, writeFileSync } from 'fs';
16
+ import { createInterface } from 'readline';
17
+
18
+ const EXPECTED_BRANCH = 'master';
19
+
20
+ const c = {
21
+ r: '\x1b[0;31m',
22
+ g: '\x1b[0;32m',
23
+ y: '\x1b[0;33m',
24
+ m: '\x1b[0;35m',
25
+ 0: '\x1b[0m',
26
+ };
27
+
28
+ const args = process.argv.slice(2);
29
+ const noBump = args.includes('--no-bump') || args.includes('-n');
30
+ const addAll = args.includes('--add-all') || args.includes('-a');
31
+
32
+ if (args.includes('--help') || args.includes('-h')) {
33
+ console.log('Usage: node scripts/publish.js [--no-bump|-n] [--add-all|-a]');
34
+ console.log(' --no-bump, -n Publish current version without bumping the patch number');
35
+ console.log(' --add-all, -a Also stage untracked files (git add --all).');
36
+ console.log(' By default only modified tracked files are staged (git add -u).');
37
+ process.exit(0);
38
+ }
39
+
40
+ function pause(msg = 'Press Enter to continue ...') {
41
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
42
+ return new Promise((resolve) => rl.question(msg, () => {
43
+ rl.close();
44
+ resolve();
45
+ }));
46
+ }
47
+
48
+ async function abort(msg) {
49
+ console.error(`${c.r}${msg || '**** ERROR ****'}${c[0]}`);
50
+ process.exit(0);
51
+ }
52
+
53
+ function run(cmd) {
54
+ const result = spawnSync(cmd, { shell: true, stdio: 'inherit' });
55
+ return result.status ?? 1;
56
+ }
57
+
58
+ function bumpVersion() {
59
+ const pkgPath = 'package.json';
60
+ const pkgRaw = readFileSync(pkgPath, 'utf8');
61
+ const pkg = JSON.parse(pkgRaw);
62
+ const oldVersion = pkg.version;
63
+ console.log(`${c.m}**** Old version is ${c.g}${oldVersion}${c.m} ****${c[0]}`);
64
+
65
+ const [major = 0, minor = 0, patch = 0] = oldVersion.split('.').map(Number);
66
+ const newVersion = `${major}.${minor}.${patch + 1}`;
67
+
68
+ console.log(
69
+ `${c.m}**** Bumping version of ${c.g}${pkg.name}${c.m}: ${c.y}${oldVersion}${c.m} -> ${c.g}${newVersion}${c.m} ****${c[0]}`,
70
+ );
71
+
72
+ // Replace only the first occurrence (the package's own "version" field).
73
+ writeFileSync(pkgPath, pkgRaw.replace(oldVersion, newVersion));
74
+
75
+ // Update fa-mcp-sdk dependency in cli-template/package.json: "fa-mcp-sdk": "^X.Y.Z"
76
+ const tplPath = 'cli-template/package.json';
77
+ const tplRaw = readFileSync(tplPath, 'utf8');
78
+ writeFileSync(tplPath, tplRaw.replace(/("fa-mcp-sdk":\s*")\^?[^"]+(")/, `$1^${newVersion}$2`));
79
+
80
+ return newVersion;
81
+ }
82
+
83
+ async function main() {
84
+ let branchName;
85
+ try {
86
+ branchName = execSync('git symbolic-ref --short HEAD', { encoding: 'utf8' }).trim();
87
+ } catch {
88
+ await abort(`${c.y}**** Version will not be bumped since retcode is not equals 0 ****${c[0]}`);
89
+ }
90
+
91
+ if (branchName !== EXPECTED_BRANCH) {
92
+ console.log(
93
+ `${c.y}**** git branch should be ${c.m}{${EXPECTED_BRANCH}}${c.y}, current: ${c.m}${branchName}${c.y} ****${c[0]}`,
94
+ );
95
+ process.exit(0);
96
+ }
97
+
98
+ if (run('npm run cb') !== 0) {
99
+ await abort(`${c.y}**** Typescript build failed ****${c[0]}`);
100
+ }
101
+
102
+ let version;
103
+ if (noBump) {
104
+ version = JSON.parse(readFileSync('package.json', 'utf8')).version;
105
+ console.log(`${c.y}**** Skipping version bump, publishing current ${c.g}${version}${c.y} ****${c[0]}`);
106
+ } else {
107
+ version = bumpVersion();
108
+ }
109
+
110
+ // -u stages modifications/deletions to tracked files (incl. the bumped package.json files),
111
+ // but does NOT include untracked files. --add-all switches to `git add --all` (also untracked).
112
+ const stageCmd = addAll ? 'git add --all' : 'git add -u';
113
+ if (run(stageCmd) !== 0) await abort();
114
+
115
+ const staged = execSync('git diff --cached --name-only', { encoding: 'utf8' }).trim();
116
+ if (staged) {
117
+ if (run(`git commit --no-verify -m "${version}"`) !== 0) await abort();
118
+ if (run(`git push origin refs/heads/${EXPECTED_BRANCH}:${EXPECTED_BRANCH}`) !== 0) await abort();
119
+ } else {
120
+ console.log(`${c.y}**** Nothing staged, skipping git commit/push ****${c[0]}`);
121
+ }
122
+
123
+ run('npm publish');
124
+ process.exit(0);
125
+ }
126
+
127
+ main();
@@ -1,78 +0,0 @@
1
- #!/bin/bash
2
-
3
- expected_branch="master"
4
-
5
- c='\033[0;35m'
6
- y='\033[0;33m'
7
- r='\033[0;31m'
8
- c0='\033[0;0m'
9
- g='\033[0;32m'
10
-
11
- echo_r() { /bin/echo -e ${r}"$1"${c0}; };
12
-
13
- # shellcheck disable=SC2120
14
- exit_on_error(){
15
- if [[ $? -ne 0 ]] ; then
16
- if [[ -n "$1" ]]; then
17
- echo_r "$1";
18
- else
19
- echo -e "${r}**** ERROR ****${c0}"
20
- fi;
21
- read -p "Press any key to resume ..."
22
- exit 0
23
- fi
24
- }
25
-
26
- set +e
27
-
28
- branch_name=$(git symbolic-ref --short HEAD)
29
- exit_on_error "$y**** Version will not be bumped since retcode is not equals 0 ****$c0"
30
-
31
- if [[ "$branch_name" != "$expected_branch" ]] ; then
32
- echo -e "${y}**** git branch should be ${c}{$expected_branch}${y}, current: ${c}${branch_name}${y} ****$c0"
33
- read -p "Press any key to resume ..."
34
- exit 0
35
- fi
36
-
37
- npm run cb
38
- exit_on_error "$y**** Typescript build failed ****$c0"
39
-
40
- old_version=''
41
- new_version=''
42
-
43
- update_version(){
44
- old_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
45
- echo -e "$c**** Old version is $g$old_version$c ****$c0"
46
- version_split=( ${old_version//./ } )
47
- major=${version_split[0]:-0}
48
- minor=${version_split[1]:-0}
49
- patch=${version_split[2]:-0}
50
- let "patch=patch+1"
51
- new_version="${major}.${minor}.${patch}"
52
-
53
- repo=`cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
54
- echo -e "$c**** Bumping version of $g$repo$c: $y$old_version$c -> $g$new_version$c ****$c0"
55
- sed -i -e "0,/$old_version/s/$old_version/$new_version/" package.json
56
- # Update the dependency version in cli-template/package.json: "fa-mcp-sdk": "^<new_version>"
57
- # Version match is built on a regular expression that allows any current version (with an optional ^)
58
- sed -i -E "s/(\"fa-mcp-sdk\":\s*\")\^?[^\"]+(\"[,\r\n\s]*)/\1^${new_version}\2/" cli-template/package.json
59
- echo -e "$g"
60
- npm version 2>&1 | head -2 | tail -1
61
- echo -e "$c0"
62
- }
63
-
64
-
65
- update_version
66
- exit_on_error
67
-
68
- git add --all
69
- exit_on_error
70
-
71
- git commit --no-verify -m "$new_version"
72
- exit_on_error
73
-
74
- git push origin refs/heads/${expected_branch}:${expected_branch}
75
- exit_on_error
76
- # npm pack --dry-run
77
- npm publish
78
- read -p "Press any key to resume ..."