@forwardimpact/pathway 0.25.9 → 0.25.10
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/fit-pathway.js +1 -1
- package/package.json +1 -1
- package/src/commands/update.js +12 -12
- package/templates/install.template.sh +10 -8
package/bin/fit-pathway.js
CHANGED
|
@@ -104,7 +104,7 @@ GETTING STARTED
|
|
|
104
104
|
init Create ./data/ with example data
|
|
105
105
|
dev [--port=PORT] Run live development server
|
|
106
106
|
build [--output=PATH] [--url=URL] Generate static site + distribution bundle
|
|
107
|
-
update [--url=URL] Update local ~/.fit/pathway/ installation
|
|
107
|
+
update [--url=URL] Update local ~/.fit/data/pathway/ installation
|
|
108
108
|
|
|
109
109
|
────────────────────────────────────────────────────────────────────────────────
|
|
110
110
|
ENTITY COMMANDS
|
package/package.json
CHANGED
package/src/commands/update.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Update Command
|
|
3
3
|
*
|
|
4
4
|
* Re-downloads the distribution bundle from the published site URL
|
|
5
|
-
* and updates the local ~/.fit/pathway/ installation.
|
|
5
|
+
* and updates the local ~/.fit/data/pathway/ installation.
|
|
6
6
|
* Updates the global @forwardimpact/pathway package if the version changed.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -10,9 +10,11 @@ import { cp, mkdir, rm, readFile, writeFile, access } from "fs/promises";
|
|
|
10
10
|
import { join } from "path";
|
|
11
11
|
import { homedir } from "os";
|
|
12
12
|
import { execFileSync } from "child_process";
|
|
13
|
+
import { tmpdir } from "os";
|
|
13
14
|
import { createDataLoader } from "@forwardimpact/map/loader";
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const BASE_DIR = join(homedir(), ".fit", "data");
|
|
17
|
+
const INSTALL_DIR = join(BASE_DIR, "pathway");
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Run the update command.
|
|
@@ -24,13 +26,11 @@ const INSTALL_DIR = join(homedir(), ".fit", "pathway");
|
|
|
24
26
|
* @param {Object} params.options - Command options
|
|
25
27
|
*/
|
|
26
28
|
export async function runUpdateCommand({ dataDir: _dataDir, options }) {
|
|
27
|
-
const installDataDir = join(INSTALL_DIR, "data");
|
|
28
|
-
|
|
29
29
|
// Verify we have a home-directory installation
|
|
30
30
|
try {
|
|
31
|
-
await access(
|
|
31
|
+
await access(INSTALL_DIR);
|
|
32
32
|
} catch {
|
|
33
|
-
console.error("Error: No local installation found at ~/.fit/pathway/");
|
|
33
|
+
console.error("Error: No local installation found at ~/.fit/data/pathway/");
|
|
34
34
|
console.error(
|
|
35
35
|
"Install first using the install.sh script from your organization's pathway site.",
|
|
36
36
|
);
|
|
@@ -39,12 +39,12 @@ export async function runUpdateCommand({ dataDir: _dataDir, options }) {
|
|
|
39
39
|
|
|
40
40
|
// Load framework config to get siteUrl
|
|
41
41
|
const loader = createDataLoader();
|
|
42
|
-
const framework = await loader.loadFrameworkConfig(
|
|
42
|
+
const framework = await loader.loadFrameworkConfig(INSTALL_DIR);
|
|
43
43
|
const siteUrl = options.url || framework.distribution?.siteUrl;
|
|
44
44
|
|
|
45
45
|
if (!siteUrl) {
|
|
46
46
|
console.error(
|
|
47
|
-
"Error: No siteUrl found in ~/.fit/pathway/
|
|
47
|
+
"Error: No siteUrl found in ~/.fit/data/pathway/framework.yaml (distribution.siteUrl)",
|
|
48
48
|
);
|
|
49
49
|
console.error("Provide one with --url=<URL> or add it to framework.yaml.");
|
|
50
50
|
process.exit(1);
|
|
@@ -56,7 +56,7 @@ export async function runUpdateCommand({ dataDir: _dataDir, options }) {
|
|
|
56
56
|
console.log(`\n🔄 Updating from ${baseUrl}...\n`);
|
|
57
57
|
|
|
58
58
|
// 1. Download bundle to temp location
|
|
59
|
-
const tmpDir = join(
|
|
59
|
+
const tmpDir = join(tmpdir(), "fit-pathway-update");
|
|
60
60
|
await mkdir(tmpDir, { recursive: true });
|
|
61
61
|
|
|
62
62
|
const tmpBundle = join(tmpDir, bundleName);
|
|
@@ -86,7 +86,7 @@ export async function runUpdateCommand({ dataDir: _dataDir, options }) {
|
|
|
86
86
|
|
|
87
87
|
// 3. Compare versions from bundle's package.json (version manifest)
|
|
88
88
|
const newPkgPath = join(extractDir, "package.json");
|
|
89
|
-
const oldPkgPath = join(
|
|
89
|
+
const oldPkgPath = join(BASE_DIR, "package.json");
|
|
90
90
|
const newPkg = JSON.parse(await readFile(newPkgPath, "utf8"));
|
|
91
91
|
let oldPkg;
|
|
92
92
|
try {
|
|
@@ -102,8 +102,8 @@ export async function runUpdateCommand({ dataDir: _dataDir, options }) {
|
|
|
102
102
|
|
|
103
103
|
// 4. Replace data
|
|
104
104
|
console.log(" Updating data files...");
|
|
105
|
-
await rm(
|
|
106
|
-
await cp(join(extractDir, "data"),
|
|
105
|
+
await rm(INSTALL_DIR, { recursive: true });
|
|
106
|
+
await cp(join(extractDir, "data"), INSTALL_DIR, { recursive: true });
|
|
107
107
|
console.log(" ✓ Data updated");
|
|
108
108
|
|
|
109
109
|
// 5. Update version manifest
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Generated by @forwardimpact/pathway v{{{version}}}
|
|
4
4
|
#
|
|
5
5
|
# Installs fit-pathway globally via bun and downloads organization data
|
|
6
|
-
# to ~/.fit/pathway
|
|
6
|
+
# to ~/.fit/data/pathway/.
|
|
7
7
|
#
|
|
8
8
|
# Usage:
|
|
9
9
|
# curl -fsSL {{{siteUrl}}}/install.sh | bash
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
set -euo pipefail
|
|
12
12
|
|
|
13
13
|
SITE_URL="{{{siteUrl}}}"
|
|
14
|
-
INSTALL_DIR="${HOME}/.fit/pathway"
|
|
14
|
+
INSTALL_DIR="${HOME}/.fit/data/pathway"
|
|
15
15
|
|
|
16
16
|
command -v bun >/dev/null 2>&1 || { echo "Error: Bun 1.2+ is required. https://bun.sh"; exit 1; }
|
|
17
17
|
|
|
@@ -19,14 +19,16 @@ command -v bun >/dev/null 2>&1 || { echo "Error: Bun 1.2+ is required. https://b
|
|
|
19
19
|
echo "Installing @forwardimpact/pathway globally..."
|
|
20
20
|
bun install -g @forwardimpact/pathway@{{{version}}}
|
|
21
21
|
|
|
22
|
-
# Download organization data to ~/.fit/pathway/
|
|
23
|
-
echo "Downloading organization data to ${INSTALL_DIR}
|
|
22
|
+
# Download organization data to ~/.fit/data/pathway/
|
|
23
|
+
echo "Downloading organization data to ${INSTALL_DIR}..."
|
|
24
24
|
mkdir -p "${INSTALL_DIR}"
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
trap 'rm -
|
|
28
|
-
curl -fsSL "${SITE_URL}/bundle.tar.gz" -o "$
|
|
29
|
-
tar -xzf "$
|
|
26
|
+
TMPDIR_INSTALL=$(mktemp -d)
|
|
27
|
+
trap 'rm -rf "$TMPDIR_INSTALL"' EXIT
|
|
28
|
+
curl -fsSL "${SITE_URL}/bundle.tar.gz" -o "${TMPDIR_INSTALL}/bundle.tar.gz"
|
|
29
|
+
tar -xzf "${TMPDIR_INSTALL}/bundle.tar.gz" -C "${TMPDIR_INSTALL}" --strip-components=1
|
|
30
|
+
cp -R "${TMPDIR_INSTALL}/data/." "${INSTALL_DIR}/"
|
|
31
|
+
cp "${TMPDIR_INSTALL}/package.json" "${HOME}/.fit/data/package.json" 2>/dev/null || true
|
|
30
32
|
|
|
31
33
|
echo ""
|
|
32
34
|
echo "Done. Usage:"
|