@geosynk/vertigis-web-sdk 1.0.11 → 1.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/README.md +72 -9
- package/package.json +6 -6
- package/scripts/create.js +12 -2
- package/template/package.json +1 -1
- package/template-custom/AGENTS.md +86 -33
- package/template-custom/Dockerfile.build +46 -0
- package/template-custom/build.bat +84 -5
- package/template-custom/build.sh +82 -2
- package/template-custom/certs/generate-cert.bat +10 -9
- package/template-custom/certs/generate-cert.sh +1 -0
- package/template-custom/project.config +107 -0
- package/template-custom/scripts/configure-portal.js +56 -7
- package/template-custom/scripts/load-config.bat +12 -0
- package/template-custom/scripts/load-config.sh +26 -0
- package/template-custom/scripts/remote-sync.bat +12 -0
- package/template-custom/scripts/remote-sync.sh +42 -0
- package/template-custom/scripts/verify_zero_cosmetic_sx.py +419 -0
- package/template-custom/src/auth/index.ts +18 -1
- package/template-custom/src/components/CustomWidget/CustomWidget.css +1 -0
- package/template-custom/src/components/CustomWidget/CustomWidget.tsx +28 -49
- package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.css +0 -0
- package/template-custom/src/components/CustomWidget/components/CustomWidgetErrorBoundary.tsx +12 -19
- package/template-custom/src/index.ts +4 -1
- package/template-custom/src/tokens/VertiGisThemeProvider.tsx +14 -0
- package/template-custom/src/tokens/index.ts +3 -0
- package/template-custom/src/tokens/muiTheme.ts +61 -0
- package/template-custom/src/tokens/spacing.ts +24 -0
- package/template-custom/src/tokens/typography.ts +0 -4
- package/template-custom/src/tokens/ui.ts +58 -3
- package/template-custom/start.bat +24 -1
- package/template-custom/start.sh +35 -0
- package/template-custom/webpack.config.js +46 -161
package/template-custom/build.sh
CHANGED
|
@@ -1,7 +1,67 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
# Usage: ./build.sh [name]
|
|
5
|
+
# Build build/<name>.js and build/<name>.js.txt.
|
|
6
|
+
# ./build.sh upload-gc [public-url] [name]
|
|
7
|
+
# Build, then upload build/<name>.js to Google Cloud Storage with gcloud.
|
|
8
|
+
#
|
|
9
|
+
# Values that you do not give on the command line come from project.config:
|
|
10
|
+
# BUILD_NAME, GC_UPLOAD_URL, GC_CACHE_CONTROL. See project.config for the description of each value.
|
|
11
|
+
#
|
|
12
|
+
# <public-url> is https://storage.googleapis.com/<bucket>/<path> or gs://<bucket>/<path>.
|
|
13
|
+
# If the URL ends with ".js", it is the object name. Otherwise it is a folder and the file is <name>.js in it.
|
|
14
|
+
# The bucket must already allow public read (allUsers: Storage Object Viewer). This script does not change access.
|
|
15
|
+
|
|
16
|
+
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
17
|
+
# shellcheck source=scripts/load-config.sh
|
|
18
|
+
source ./scripts/load-config.sh
|
|
19
|
+
|
|
20
|
+
UPLOAD=""
|
|
21
|
+
UPLOAD_URL=""
|
|
22
|
+
if [ "${1:-}" = "upload-gc" ]; then
|
|
23
|
+
UPLOAD=1
|
|
24
|
+
shift
|
|
25
|
+
if [ $# -gt 0 ]; then
|
|
26
|
+
UPLOAD_URL="$1"
|
|
27
|
+
shift
|
|
28
|
+
fi
|
|
29
|
+
UPLOAD_URL="${UPLOAD_URL:-${CFG_GC_UPLOAD_URL:-}}"
|
|
30
|
+
if [ -z "$UPLOAD_URL" ]; then
|
|
31
|
+
echo "Usage: ./build.sh upload-gc <public-url> [name]" >&2
|
|
32
|
+
echo " Or set GC_UPLOAD_URL in project.config and run: ./build.sh upload-gc" >&2
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
NAME="${1:-${CFG_BUILD_NAME:-__PROJECT_NAME__}}"
|
|
38
|
+
CACHE_CONTROL="${CFG_GC_CACHE_CONTROL:-no-cache}"
|
|
39
|
+
|
|
40
|
+
# Check the upload settings before the build, so that a bad URL fails fast.
|
|
41
|
+
GS_OBJECT=""
|
|
42
|
+
if [ -n "$UPLOAD" ]; then
|
|
43
|
+
case "$UPLOAD_URL" in
|
|
44
|
+
gs://*) GS_PATH="${UPLOAD_URL#gs://}" ;;
|
|
45
|
+
https://storage.googleapis.com/*) GS_PATH="${UPLOAD_URL#https://storage.googleapis.com/}" ;;
|
|
46
|
+
*)
|
|
47
|
+
echo "Error: the URL must start with https://storage.googleapis.com/ or gs://" >&2
|
|
48
|
+
exit 1
|
|
49
|
+
;;
|
|
50
|
+
esac
|
|
51
|
+
if [ -z "${GS_PATH%%/*}" ]; then
|
|
52
|
+
echo "Error: no bucket name in $UPLOAD_URL" >&2
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
case "$GS_PATH" in
|
|
56
|
+
*.js) GS_OBJECT="$GS_PATH" ;;
|
|
57
|
+
*/) GS_OBJECT="${GS_PATH}${NAME}.js" ;;
|
|
58
|
+
*) GS_OBJECT="${GS_PATH}/${NAME}.js" ;;
|
|
59
|
+
esac
|
|
60
|
+
if ! command -v gcloud >/dev/null 2>&1; then
|
|
61
|
+
echo "Error: gcloud not found. Install the Google Cloud CLI and run: gcloud auth login" >&2
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
5
65
|
|
|
6
66
|
npm run build
|
|
7
67
|
|
|
@@ -10,6 +70,26 @@ if [ ! -f "build/main.js" ]; then
|
|
|
10
70
|
exit 1
|
|
11
71
|
fi
|
|
12
72
|
|
|
73
|
+
# Production gate: the dev OAuth code (src/auth) must not be in the bundle. It is removed only when
|
|
74
|
+
# NODE_ENV is "production" (the SDK build command sets it). "localtest.me" is the dev host, and
|
|
75
|
+
# "oauth_callback" is the dev popup callback page. If your library uses its own OAuth callback in
|
|
76
|
+
# production, rename that page or change this check.
|
|
77
|
+
for DEV_MARKER in "localtest.me" "oauth_callback"; do
|
|
78
|
+
if grep -Fq "$DEV_MARKER" "build/main.js"; then
|
|
79
|
+
echo "Error: dev OAuth URL ($DEV_MARKER) detected in build/main.js. Dev OAuth hijacked production bundle." >&2
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|
|
82
|
+
done
|
|
83
|
+
|
|
13
84
|
cp -f "build/main.js" "build/${NAME}.js"
|
|
14
85
|
cp -f "build/main.js" "build/${NAME}.js.txt"
|
|
15
|
-
echo "Created build/${NAME}.js and build/${NAME}.js.txt"
|
|
86
|
+
echo "Created build/${NAME}.js and build/${NAME}.js.txt (verified zero dev URLs)"
|
|
87
|
+
|
|
88
|
+
if [ -n "$GS_OBJECT" ]; then
|
|
89
|
+
echo "Uploading build/${NAME}.js to gs://${GS_OBJECT} (Cache-Control: ${CACHE_CONTROL})..."
|
|
90
|
+
gcloud storage cp "build/${NAME}.js" "gs://${GS_OBJECT}" \
|
|
91
|
+
--content-type="application/javascript" \
|
|
92
|
+
--cache-control="${CACHE_CONTROL}"
|
|
93
|
+
echo "Uploaded. Public URL (add it in Designer > App Settings > Custom Libraries):"
|
|
94
|
+
echo " https://storage.googleapis.com/${GS_OBJECT}"
|
|
95
|
+
fi
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
@echo off
|
|
2
2
|
setlocal
|
|
3
3
|
set CERTS_DIR=%~dp0
|
|
4
|
-
if
|
|
5
|
-
echo [INFO] Generating self-signed development SSL certificate via OpenSSL...
|
|
6
|
-
openssl req -x509 -newkey rsa:2048 -keyout "%CERTS_DIR%key.pem" -out "%CERTS_DIR%cert.pem" -days 365 -nodes -subj "/CN=localtest.me" -addext "subjectAltName=DNS:localtest.me,DNS:*.localtest.me,DNS:localhost,DNS:*.localhost,IP:127.0.0.1"
|
|
7
|
-
if %ERRORLEVEL% EQU 0 (
|
|
8
|
-
echo [SUCCESS] SSL certificate and private key generated in certs/ with SAN (localtest.me, localhost, 127.0.0.1)
|
|
9
|
-
) else (
|
|
10
|
-
echo [WARN] OpenSSL command failed. Please ensure openssl is installed and in your PATH.
|
|
11
|
-
)
|
|
12
|
-
) else (
|
|
4
|
+
if exist "%CERTS_DIR%cert.pem" if exist "%CERTS_DIR%key.pem" (
|
|
13
5
|
echo [INFO] SSL certificate already exists in certs/
|
|
6
|
+
exit /b 0
|
|
14
7
|
)
|
|
8
|
+
echo [INFO] Generating self-signed development SSL certificate via OpenSSL...
|
|
9
|
+
openssl req -x509 -newkey rsa:2048 -keyout "%CERTS_DIR%key.pem" -out "%CERTS_DIR%cert.pem" -days 365 -nodes -subj "/CN=localtest.me" -addext "subjectAltName=DNS:localtest.me,DNS:*.localtest.me,DNS:localhost,DNS:*.localhost,IP:127.0.0.1"
|
|
10
|
+
if errorlevel 1 (
|
|
11
|
+
echo [WARN] OpenSSL command failed. Please ensure openssl is installed and in your PATH.
|
|
12
|
+
exit /b 1
|
|
13
|
+
)
|
|
14
|
+
echo [SUCCESS] SSL certificate and private key generated in certs/ with SAN (localtest.me, localhost, 127.0.0.1)
|
|
15
|
+
echo [INFO] To make the browser trust it, run once: certutil -addstore -user Root "%CERTS_DIR%cert.pem"
|
|
@@ -9,6 +9,7 @@ if [ ! -f "$CERTS_DIR/cert.pem" ] || [ ! -f "$CERTS_DIR/key.pem" ]; then
|
|
|
9
9
|
-subj "/CN=localtest.me" \
|
|
10
10
|
-addext "subjectAltName=DNS:localtest.me,DNS:*.localtest.me,DNS:localhost,DNS:*.localhost,IP:127.0.0.1"
|
|
11
11
|
echo "[SUCCESS] SSL certificate and private key generated in certs/ with SAN (localtest.me, localhost, 127.0.0.1)"
|
|
12
|
+
echo "[INFO] To make the browser trust it, add $CERTS_DIR/cert.pem to the trusted root certificates of your OS."
|
|
12
13
|
else
|
|
13
14
|
echo "[INFO] SSL certificate already exists in certs/"
|
|
14
15
|
fi
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Project configuration for the scripts in this project
|
|
3
|
+
# ==============================================================================
|
|
4
|
+
# These scripts read this file:
|
|
5
|
+
# build.sh / build.bat BUILD_*, GC_*
|
|
6
|
+
# start.sh / start.bat REMOTE_*
|
|
7
|
+
# npm run auth:portal PORTAL_*
|
|
8
|
+
#
|
|
9
|
+
# Format:
|
|
10
|
+
# - One KEY=VALUE on each line. Do not put spaces around "=".
|
|
11
|
+
# - Do not put quotes around a value. Do not put a comment after a value.
|
|
12
|
+
# - A line that starts with "#" is a comment.
|
|
13
|
+
# - An empty value (KEY=) means "not set". The script then uses its default.
|
|
14
|
+
# - Do not use "!" in a value. Windows .bat scripts remove it.
|
|
15
|
+
#
|
|
16
|
+
# Priority (the first one that has a value wins):
|
|
17
|
+
# 1. An argument on the command line, for example: ./build.sh upload-gc <public-url> <name>
|
|
18
|
+
# 2. project.config (this file)
|
|
19
|
+
# 3. The default value in the script
|
|
20
|
+
#
|
|
21
|
+
# This file is committed to git, so it is shared with your team. Do not put passwords or tokens in it.
|
|
22
|
+
# The scripts do not run this file as code. They only read KEY=VALUE lines.
|
|
23
|
+
# ==============================================================================
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# ------------------------------------------------------------------------------
|
|
27
|
+
# Build (build.sh / build.bat)
|
|
28
|
+
# ------------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
# The name of the built library. The build copies build/main.js to build/<BUILD_NAME>.js and
|
|
31
|
+
# build/<BUILD_NAME>.js.txt.
|
|
32
|
+
# Default: the project folder name.
|
|
33
|
+
BUILD_NAME=__PROJECT_NAME__
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ------------------------------------------------------------------------------
|
|
37
|
+
# Upload to Google Cloud Storage (build.sh upload-gc / build.bat upload-gc)
|
|
38
|
+
# ------------------------------------------------------------------------------
|
|
39
|
+
# Prerequisites: install the Google Cloud CLI and sign in with: gcloud auth login
|
|
40
|
+
# The bucket must already allow public read (allUsers: Storage Object Viewer).
|
|
41
|
+
# The scripts do not change the access of the bucket.
|
|
42
|
+
|
|
43
|
+
# The upload target. If you set it, you can run "./build.sh upload-gc" without a URL.
|
|
44
|
+
# Formats: https://storage.googleapis.com/<bucket>/<path> or gs://<bucket>/<path>
|
|
45
|
+
# - If the value ends with ".js", it is the file name.
|
|
46
|
+
# - If not, it is a folder, and the file is <BUILD_NAME>.js in that folder.
|
|
47
|
+
# Example: GC_UPLOAD_URL=https://storage.googleapis.com/my-bucket/libs/
|
|
48
|
+
# Default: not set. Then you must give the URL on the command line.
|
|
49
|
+
GC_UPLOAD_URL=
|
|
50
|
+
|
|
51
|
+
# The Cache-Control header of the uploaded file.
|
|
52
|
+
# "no-cache" makes VertiGIS Studio Web load the new version at the next app load.
|
|
53
|
+
# Without it, Google Cloud Storage can serve the old version for up to 1 hour.
|
|
54
|
+
# Example: GC_CACHE_CONTROL=public, max-age=300
|
|
55
|
+
# Default: no-cache
|
|
56
|
+
GC_CACHE_CONTROL=no-cache
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# ------------------------------------------------------------------------------
|
|
60
|
+
# Remote sync (start.sh remote / start.bat remote)
|
|
61
|
+
# ------------------------------------------------------------------------------
|
|
62
|
+
# Remote mode pulls origin/<branch>, then fetches it again at an interval while the dev server runs.
|
|
63
|
+
# It fast-forwards only. It does not change your local commits or uncommitted changes.
|
|
64
|
+
|
|
65
|
+
# Set to true to use remote mode also when you run "./start.sh" without "remote".
|
|
66
|
+
# Default: false
|
|
67
|
+
REMOTE_SYNC=false
|
|
68
|
+
|
|
69
|
+
# The branch to sync with.
|
|
70
|
+
# Default: not set. Then the script uses the current branch.
|
|
71
|
+
REMOTE_BRANCH=
|
|
72
|
+
|
|
73
|
+
# The time between two fetches, in seconds.
|
|
74
|
+
# Default: 5
|
|
75
|
+
REMOTE_INTERVAL=5
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# ------------------------------------------------------------------------------
|
|
79
|
+
# Portal authentication (npm run auth:portal)
|
|
80
|
+
# ------------------------------------------------------------------------------
|
|
81
|
+
# If PORTAL_URL and PORTAL_CLIENT_ID both have a value, "npm run auth:portal" does not ask questions.
|
|
82
|
+
# It writes app/auth/portal.json and src/auth/portalConfig.json from these values.
|
|
83
|
+
# If one of them is empty, the script asks for the missing values.
|
|
84
|
+
#
|
|
85
|
+
# Note: these values are not secrets. The OAuth client ID is public, and the build puts it in the bundle.
|
|
86
|
+
|
|
87
|
+
# The URL of your ArcGIS Enterprise portal or ArcGIS Online organization.
|
|
88
|
+
# Example: PORTAL_URL=https://gis.example.com/portal
|
|
89
|
+
PORTAL_URL=
|
|
90
|
+
|
|
91
|
+
# The Client ID of the OAuth application that you registered in the portal
|
|
92
|
+
# (Content > Add Item > Application).
|
|
93
|
+
PORTAL_CLIENT_ID=
|
|
94
|
+
|
|
95
|
+
# The account ID (organization identifier).
|
|
96
|
+
# Default: if the script asks questions, it suggests the first part of the portal host name
|
|
97
|
+
# (for example "gis" for gis.example.com). If it does not ask questions, the default is "enterprise".
|
|
98
|
+
PORTAL_ACCOUNT_ID=
|
|
99
|
+
|
|
100
|
+
# The web map to show in app/app.json. Use the item ID (32 characters) or the full item URL.
|
|
101
|
+
# Default: not set. Then the script does not change the web map.
|
|
102
|
+
PORTAL_WEBMAP=
|
|
103
|
+
|
|
104
|
+
# More origins that you use for preview, separated by commas. The script shows them in the list of
|
|
105
|
+
# redirect URIs and allowed origins that you must add in the portal. https://localtest.me:3001 is always shown.
|
|
106
|
+
# Example: PORTAL_PREVIEW_ORIGINS=https://preview.example.com,https://test.example.com
|
|
107
|
+
PORTAL_PREVIEW_ORIGINS=https://preview.kw11.org
|
|
@@ -14,6 +14,34 @@ const oauthCallbackPath = path.join(projRoot, "app/oauth_callback.html");
|
|
|
14
14
|
|
|
15
15
|
const args = process.argv.slice(2);
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Reads project.config from the project root.
|
|
19
|
+
* Each KEY=VALUE line becomes one entry. Lines that start with "#" and empty lines are ignored.
|
|
20
|
+
* An empty value means "not set".
|
|
21
|
+
* See project.config for the description of each PORTAL_* value.
|
|
22
|
+
* @returns {Record<string, string>}
|
|
23
|
+
*/
|
|
24
|
+
function readProjectConfig() {
|
|
25
|
+
/** @type {Record<string, string>} */
|
|
26
|
+
const values = {};
|
|
27
|
+
for (const name of ["project.config"]) {
|
|
28
|
+
const file = path.join(projRoot, name);
|
|
29
|
+
if (!fs.existsSync(file)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
for (const line of fs.readFileSync(file, "utf-8").split(/\r?\n/)) {
|
|
33
|
+
const idx = line.indexOf("=");
|
|
34
|
+
if (!line || line.startsWith("#") || idx <= 0) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
values[line.slice(0, idx)] = line.slice(idx + 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return values;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const projectConfig = readProjectConfig();
|
|
44
|
+
|
|
17
45
|
function printHelp() {
|
|
18
46
|
console.log(`
|
|
19
47
|
================================================================================
|
|
@@ -24,6 +52,10 @@ Usage:
|
|
|
24
52
|
npm run auth:portal
|
|
25
53
|
npm run auth:portal -- [options]
|
|
26
54
|
|
|
55
|
+
Values that you do not give as options come from project.config:
|
|
56
|
+
PORTAL_URL, PORTAL_CLIENT_ID, PORTAL_ACCOUNT_ID, PORTAL_WEBMAP, PORTAL_PREVIEW_ORIGINS.
|
|
57
|
+
If PORTAL_URL and PORTAL_CLIENT_ID both have a value, the script does not ask questions.
|
|
58
|
+
|
|
27
59
|
Options:
|
|
28
60
|
--portal <url> [Required] ArcGIS Enterprise Portal or AGOL URL (e.g. https://gis.{org}.com/portal)
|
|
29
61
|
--client-id <id> [Required] Portal OAuth Application Client ID
|
|
@@ -106,10 +138,16 @@ async function main() {
|
|
|
106
138
|
process.exit(0);
|
|
107
139
|
}
|
|
108
140
|
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
let
|
|
112
|
-
|
|
141
|
+
// Priority: command-line option, then project.config.
|
|
142
|
+
let portalUrl = getArgValue("--portal") || projectConfig.PORTAL_URL || null;
|
|
143
|
+
let appId =
|
|
144
|
+
getArgValue("--client-id") ||
|
|
145
|
+
getArgValue("--clientId") ||
|
|
146
|
+
getArgValue("--app-id") ||
|
|
147
|
+
projectConfig.PORTAL_CLIENT_ID ||
|
|
148
|
+
null;
|
|
149
|
+
let accountId = getArgValue("--account-id") || projectConfig.PORTAL_ACCOUNT_ID || null;
|
|
150
|
+
let webMap = getArgValue("--webmap") || getArgValue("--webMap") || projectConfig.PORTAL_WEBMAP || null;
|
|
113
151
|
|
|
114
152
|
// Load existing values as defaults if available
|
|
115
153
|
let existingConfig = {};
|
|
@@ -258,14 +296,25 @@ async function main() {
|
|
|
258
296
|
if (webMap) {
|
|
259
297
|
console.log(` - Web Map: ${webMap}`);
|
|
260
298
|
}
|
|
299
|
+
// Origins to register in the portal. Projects without PORTAL_PREVIEW_ORIGINS keep the earlier default.
|
|
300
|
+
const previewOrigins = (projectConfig.PORTAL_PREVIEW_ORIGINS ?? "https://preview.kw11.org")
|
|
301
|
+
.split(",")
|
|
302
|
+
.map(origin => origin.trim().replace(/\/+$/, ""))
|
|
303
|
+
.filter(Boolean);
|
|
304
|
+
const origins = ["https://localtest.me:3001", ...previewOrigins];
|
|
305
|
+
|
|
261
306
|
console.log("\n IMPORTANT PREREQUISITES in your Portal Configuration:");
|
|
262
307
|
console.log(" 1. OAuth App Registration (Content > Add Item > Application):");
|
|
263
308
|
console.log(" Ensure Redirect URIs include:");
|
|
264
|
-
|
|
265
|
-
|
|
309
|
+
for (const origin of origins) {
|
|
310
|
+
console.log(` • ${origin}`);
|
|
311
|
+
console.log(` • ${origin}/oauth_callback.html`);
|
|
312
|
+
}
|
|
266
313
|
console.log(" 2. Allowed Origins / CORS (Organization > Settings > Security > Allow Origins):");
|
|
267
314
|
console.log(" If cross-domain requests are restricted, whitelist your development origin:");
|
|
268
|
-
|
|
315
|
+
for (const origin of origins) {
|
|
316
|
+
console.log(` • ${origin}`);
|
|
317
|
+
}
|
|
269
318
|
console.log(" (Note: ArcGIS Enterprise requires an FQDN and rejects bare \"localhost\")");
|
|
270
319
|
console.log("\n Next Steps:");
|
|
271
320
|
console.log(" Run: npm start (or ./start.sh)");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem Reads project.config from the current folder (the project root).
|
|
3
|
+
rem build.bat and start.bat call this file. Do not run it directly.
|
|
4
|
+
rem
|
|
5
|
+
rem Each KEY=VALUE line sets the variable CFG_<KEY>. Lines that start with "#" and empty lines are ignored.
|
|
6
|
+
rem This file does not run the config as code. It only reads KEY=VALUE lines.
|
|
7
|
+
for %%F in (project.config) do (
|
|
8
|
+
if exist "%%F" (
|
|
9
|
+
for /f "usebackq eol=# tokens=1,* delims==" %%A in ("%%F") do set "CFG_%%A=%%B"
|
|
10
|
+
)
|
|
11
|
+
)
|
|
12
|
+
exit /b 0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# shellcheck shell=bash
|
|
2
|
+
# Reads project.config from the current folder (the project root).
|
|
3
|
+
# build.sh and start.sh source this file. Do not run it directly.
|
|
4
|
+
#
|
|
5
|
+
# Each KEY=VALUE line sets the shell variable CFG_<KEY>. Lines that start with "#" and empty lines are ignored.
|
|
6
|
+
# This file does not run the config as code. It only reads KEY=VALUE lines.
|
|
7
|
+
|
|
8
|
+
for _cfg_file in project.config; do
|
|
9
|
+
[ -f "$_cfg_file" ] || continue
|
|
10
|
+
_cfg_num=0
|
|
11
|
+
while IFS= read -r _cfg_line || [ -n "$_cfg_line" ]; do
|
|
12
|
+
_cfg_num=$((_cfg_num + 1))
|
|
13
|
+
_cfg_line="${_cfg_line%$'\r'}"
|
|
14
|
+
case "$_cfg_line" in
|
|
15
|
+
"" | "#"*) continue ;;
|
|
16
|
+
esac
|
|
17
|
+
_cfg_key="${_cfg_line%%=*}"
|
|
18
|
+
_cfg_value="${_cfg_line#*=}"
|
|
19
|
+
if [ "$_cfg_key" = "$_cfg_line" ] || [[ ! "$_cfg_key" =~ ^[A-Z][A-Z0-9_]*$ ]]; then
|
|
20
|
+
echo "[config] $_cfg_file line $_cfg_num is not KEY=VALUE. The line is ignored." >&2
|
|
21
|
+
continue
|
|
22
|
+
fi
|
|
23
|
+
printf -v "CFG_${_cfg_key}" '%s' "$_cfg_value"
|
|
24
|
+
done <"$_cfg_file"
|
|
25
|
+
done
|
|
26
|
+
unset _cfg_file _cfg_num _cfg_line _cfg_key _cfg_value
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
rem Keeps the local checkout in sync with origin/<branch> (fast-forward only).
|
|
3
|
+
rem Usage: scripts\remote-sync.bat <branch> [seconds]
|
|
4
|
+
setlocal
|
|
5
|
+
set BRANCH=%~1
|
|
6
|
+
set INTERVAL=%~2
|
|
7
|
+
if "%INTERVAL%"=="" set INTERVAL=5
|
|
8
|
+
:loop
|
|
9
|
+
git fetch --quiet origin %BRANCH% >nul 2>&1
|
|
10
|
+
git merge --ff-only origin/%BRANCH% >nul 2>&1 && git log -1 --format="[sync] %%h %%s"
|
|
11
|
+
timeout /t %INTERVAL% /nobreak >nul
|
|
12
|
+
goto loop
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Keeps the local checkout in sync with the remote branch (used by `start.sh remote`).
|
|
3
|
+
# Fast-forward only: it never rewrites or overwrites your local work.
|
|
4
|
+
# Usage: scripts/remote-sync.sh [branch] [interval-seconds] [--once]
|
|
5
|
+
set -uo pipefail
|
|
6
|
+
|
|
7
|
+
BRANCH="${1:-$(git rev-parse --abbrev-ref HEAD)}"
|
|
8
|
+
INTERVAL="${2:-5}"
|
|
9
|
+
ONCE="${3:-}"
|
|
10
|
+
WARNED=""
|
|
11
|
+
|
|
12
|
+
sync_once() {
|
|
13
|
+
if ! git fetch --quiet origin "$BRANCH" 2>/dev/null; then
|
|
14
|
+
return 0 # offline or remote busy: try again next round
|
|
15
|
+
fi
|
|
16
|
+
local local_sha remote_sha
|
|
17
|
+
local_sha=$(git rev-parse HEAD)
|
|
18
|
+
remote_sha=$(git rev-parse "origin/$BRANCH")
|
|
19
|
+
if [ "$local_sha" = "$remote_sha" ] || git merge-base --is-ancestor "$remote_sha" HEAD; then
|
|
20
|
+
WARNED=""
|
|
21
|
+
return 0
|
|
22
|
+
fi
|
|
23
|
+
if git merge --ff-only --quiet "origin/$BRANCH" 2>/dev/null; then
|
|
24
|
+
WARNED=""
|
|
25
|
+
echo "[sync] Updated to $(git rev-parse --short HEAD): $(git log -1 --format=%s)"
|
|
26
|
+
if ! git diff --quiet "$local_sha" HEAD -- package.json pnpm-lock.yaml package-lock.json 2>/dev/null; then
|
|
27
|
+
echo "[sync] Dependencies changed. Stop the server and run npm install."
|
|
28
|
+
fi
|
|
29
|
+
elif [ "$WARNED" != "$remote_sha" ]; then
|
|
30
|
+
WARNED="$remote_sha"
|
|
31
|
+
echo "[sync] Cannot fast-forward (local commits or uncommitted changes in the way). Commit/push or stash, then it will retry."
|
|
32
|
+
fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if [ "$ONCE" = "--once" ]; then
|
|
36
|
+
sync_once
|
|
37
|
+
exit 0
|
|
38
|
+
fi
|
|
39
|
+
while true; do
|
|
40
|
+
sync_once
|
|
41
|
+
sleep "$INTERVAL"
|
|
42
|
+
done
|