@tutorialkit-rb/cli 0.1.8 → 0.2.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/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import "yargs-parser";
|
|
|
14
14
|
// package.json
|
|
15
15
|
var package_default = {
|
|
16
16
|
name: "@tutorialkit-rb/cli",
|
|
17
|
-
version: "0.
|
|
17
|
+
version: "0.2.0",
|
|
18
18
|
description: "Interactive tutorials powered by WebContainer API",
|
|
19
19
|
author: "StackBlitz Inc.",
|
|
20
20
|
type: "module",
|
package/package.json
CHANGED
package/template/bin/build-pack
CHANGED
|
@@ -7,7 +7,7 @@ set -e
|
|
|
7
7
|
#
|
|
8
8
|
# This is the fast path (~30s) compared to the monolithic `bin/build-wasm`
|
|
9
9
|
# (~5-20min). Requires a pre-built base binary (from bin/build-ruby-base
|
|
10
|
-
# or
|
|
10
|
+
# or downloaded from GitHub Releases).
|
|
11
11
|
#
|
|
12
12
|
# Usage: ./bin/build-pack
|
|
13
13
|
|
|
@@ -38,12 +38,34 @@ if [ -f "$RUBY_WASM_DIR/dist/ruby-base.wasm" ]; then
|
|
|
38
38
|
echo " Found: local build (dist/ruby-base.wasm)"
|
|
39
39
|
fi
|
|
40
40
|
|
|
41
|
-
# 2.
|
|
41
|
+
# 2. GitHub Releases fallback
|
|
42
42
|
if [ -z "$BASE_WASM" ]; then
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
echo " Not found locally, downloading from GitHub Releases..."
|
|
44
|
+
DOWNLOAD_DIR="$RUBY_WASM_DIR/dist"
|
|
45
|
+
mkdir -p "$DOWNLOAD_DIR"
|
|
46
|
+
DOWNLOAD_PATH="$DOWNLOAD_DIR/ruby-base.wasm"
|
|
47
|
+
|
|
48
|
+
REPO="Bakaface/tutorialkit.rb"
|
|
49
|
+
|
|
50
|
+
if command -v gh &> /dev/null; then
|
|
51
|
+
TAG=$(gh release list --repo "$REPO" --json tagName --jq '[.[] | select(.tagName | startswith("ruby-base-"))][0].tagName' 2>/dev/null)
|
|
52
|
+
|
|
53
|
+
if [ -n "$TAG" ]; then
|
|
54
|
+
echo " Release: $TAG"
|
|
55
|
+
gh release download "$TAG" --repo "$REPO" --pattern "ruby-base.wasm" --dir "$DOWNLOAD_DIR" --clobber 2>/dev/null
|
|
56
|
+
|
|
57
|
+
# Also download rbconfig if not present locally
|
|
58
|
+
RBCONFIG_DIR="$RUBY_WASM_DIR/rbconfig/wasm32-wasi"
|
|
59
|
+
if [ ! -f "$RBCONFIG_DIR/rbconfig.rb" ]; then
|
|
60
|
+
mkdir -p "$RBCONFIG_DIR"
|
|
61
|
+
gh release download "$TAG" --repo "$REPO" --pattern "rbconfig.rb" --dir "$RBCONFIG_DIR" --clobber 2>/dev/null
|
|
62
|
+
fi
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
if [ -f "$DOWNLOAD_PATH" ]; then
|
|
67
|
+
BASE_WASM="$DOWNLOAD_PATH"
|
|
68
|
+
echo " Downloaded from GitHub Releases"
|
|
47
69
|
fi
|
|
48
70
|
fi
|
|
49
71
|
|
|
@@ -51,7 +73,7 @@ if [ -z "$BASE_WASM" ]; then
|
|
|
51
73
|
echo
|
|
52
74
|
echo "Error: No base WASM binary found."
|
|
53
75
|
echo "Either run 'bin/build-ruby-base' to build one,"
|
|
54
|
-
echo "or
|
|
76
|
+
echo "or ensure a ruby-base release exists on GitHub."
|
|
55
77
|
exit 1
|
|
56
78
|
fi
|
|
57
79
|
|
package/template/package.json
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"@codemirror/lang-yaml": "^6.1.2",
|
|
23
23
|
"@codemirror/legacy-modes": "^6.5.1",
|
|
24
24
|
"@nanostores/react": "0.7.2",
|
|
25
|
-
"@tutorialkit-rb/react": "0.
|
|
26
|
-
"@tutorialkit-rb/runtime": "0.
|
|
25
|
+
"@tutorialkit-rb/react": "0.2.0",
|
|
26
|
+
"@tutorialkit-rb/runtime": "0.2.0",
|
|
27
27
|
"nanostores": "^0.10.3",
|
|
28
28
|
"react": "^18.3.1",
|
|
29
29
|
"react-dom": "^18.3.1"
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@astrojs/check": "^0.7.0",
|
|
33
33
|
"@astrojs/react": "^3.6.0",
|
|
34
|
-
"@tutorialkit-rb/astro": "0.
|
|
35
|
-
"@tutorialkit-rb/theme": "0.
|
|
36
|
-
"@tutorialkit-rb/types": "0.
|
|
34
|
+
"@tutorialkit-rb/astro": "0.2.0",
|
|
35
|
+
"@tutorialkit-rb/theme": "0.2.0",
|
|
36
|
+
"@tutorialkit-rb/types": "0.2.0",
|
|
37
37
|
"@types/mdast": "^4.0.4",
|
|
38
38
|
"@types/node": "^20.14.6",
|
|
39
39
|
"@types/react": "^18.3.3",
|
|
@@ -78,28 +78,18 @@ def find_rbconfig
|
|
|
78
78
|
shipped = File.join(SCRIPT_DIR, "rbconfig", "wasm32-wasi", "rbconfig.rb")
|
|
79
79
|
return shipped if File.exist?(shipped)
|
|
80
80
|
|
|
81
|
-
# 2.
|
|
82
|
-
npm_pkg = File.join(SCRIPT_DIR, "node_modules", "@tutorialkit-rb", "ruby-3.3",
|
|
83
|
-
"rbconfig", "wasm32-wasi", "rbconfig.rb")
|
|
84
|
-
return npm_pkg if File.exist?(npm_pkg)
|
|
85
|
-
|
|
86
|
-
# 3. Fallback: generated by a previous base binary build
|
|
81
|
+
# 2. Fallback: generated by a previous base binary build
|
|
87
82
|
Dir.glob(File.join(SCRIPT_DIR, "rubies", "*/usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb")).first
|
|
88
83
|
end
|
|
89
84
|
|
|
90
85
|
def find_base_wasm
|
|
91
|
-
#
|
|
86
|
+
# Locally-built or downloaded binary (from bin/build-ruby-base or GitHub Releases)
|
|
92
87
|
local = File.join(SCRIPT_DIR, "dist", "ruby-base.wasm")
|
|
93
88
|
return local if File.exist?(local)
|
|
94
89
|
|
|
95
|
-
# 2. From @tutorialkit-rb/ruby-3.3 npm package
|
|
96
|
-
npm_pkg = File.join(SCRIPT_DIR, "node_modules", "@tutorialkit-rb", "ruby-3.3",
|
|
97
|
-
"dist", "ruby-base.wasm")
|
|
98
|
-
return npm_pkg if File.exist?(npm_pkg)
|
|
99
|
-
|
|
100
90
|
$stderr.puts "Error: No base WASM binary found."
|
|
101
91
|
$stderr.puts "Either run 'bin/build-ruby-base' to build a custom binary,"
|
|
102
|
-
$stderr.puts "or
|
|
92
|
+
$stderr.puts "or run 'bin/build-pack' which downloads from GitHub Releases."
|
|
103
93
|
exit 1
|
|
104
94
|
end
|
|
105
95
|
|
|
@@ -111,12 +101,7 @@ def find_usr_dir
|
|
|
111
101
|
return path if Dir.exist?(path)
|
|
112
102
|
end
|
|
113
103
|
|
|
114
|
-
# 2.
|
|
115
|
-
npm_pkg = File.join(SCRIPT_DIR, "node_modules", "@tutorialkit-rb", "ruby-3.3",
|
|
116
|
-
"rubies", "usr")
|
|
117
|
-
return npm_pkg if Dir.exist?(npm_pkg)
|
|
118
|
-
|
|
119
|
-
# 3. Fallback: glob for the rubies/ directory left by rbwasm
|
|
104
|
+
# 2. Fallback: glob for the rubies/ directory left by rbwasm
|
|
120
105
|
candidates = Dir.glob(File.join(SCRIPT_DIR, "rubies", "ruby-3.3-wasm32-unknown-wasip1-full-*", "usr"))
|
|
121
106
|
return candidates.first if candidates.any?
|
|
122
107
|
|
|
@@ -133,7 +118,7 @@ rbconfig_path = find_rbconfig
|
|
|
133
118
|
unless rbconfig_path
|
|
134
119
|
$stderr.puts "Error: Could not find rbconfig.rb for cross-compilation"
|
|
135
120
|
$stderr.puts "Expected at: rbconfig/wasm32-wasi/rbconfig.rb"
|
|
136
|
-
$stderr.puts "Or
|
|
121
|
+
$stderr.puts "Or run 'bin/build-ruby-base' to generate one."
|
|
137
122
|
exit 1
|
|
138
123
|
end
|
|
139
124
|
puts "rbconfig: #{rbconfig_path}"
|
|
@@ -149,7 +134,7 @@ if usr_dir
|
|
|
149
134
|
else
|
|
150
135
|
$stderr.puts "Warning: Could not find usr/ directory for /usr mapping."
|
|
151
136
|
$stderr.puts " The packed binary may be missing Ruby stdlib at /usr."
|
|
152
|
-
$stderr.puts " Run 'bin/build-ruby-base'
|
|
137
|
+
$stderr.puts " Run 'bin/build-ruby-base' to generate it."
|
|
153
138
|
end
|
|
154
139
|
puts
|
|
155
140
|
|