-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (165 loc) · 9.11 KB
/
Copy pathMakefile
File metadata and controls
184 lines (165 loc) · 9.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
run:
npm start
check:
npm run --silent check
format:
npm run format
.PHONY: oc
oc:
@if ! docker image inspect opencode-bred >/dev/null 2>&1; then \
echo "image missing, building"; \
docker build --progress=plain -t opencode-bred docker/opencode/; \
touch .oc-stamp; \
elif [ docker/opencode/Dockerfile -nt .oc-stamp ]; then \
echo "Dockerfile changed, rebuilding"; \
docker build --progress=plain -t opencode-bred docker/opencode/; \
touch .oc-stamp; \
fi
fix-node-pty:
npx electron-rebuild -w node-pty
fix-sqlite3:
npx electron-rebuild -w better-sqlite3
prep: version-sqlite fix-node-pty fix-sqlite3 fix-others fix-codemirror prep-mime
./node_modules/@cookshack/eslint-config/bin/apply-patches
rm -f lib/callsites.js
cp -r node_modules/callsites/index.js lib/callsites.mjs
npx peggy --format es -o lib/ev-parser.mjs lib/ev.pegjs
npm run prepare
prep-mime:
rm -f lib/mime.json
echo \{\} > lib/mime-by-ext.json
cp -r node_modules/mime-db/db.json lib/mime.json
npm run mime
version-sqlite:
echo -n '{ "version": "' > lib/sqlite.json
grep -m 1 -oE 'version ([0-9]+\.[0-9]+\.[0-9]+)' node_modules/better-sqlite3/deps/sqlite3/sqlite3.c | cut -d' ' -f2- | tr -d '\n' >> lib/sqlite.json
echo '" }' >> lib/sqlite.json
version-codemirror:
echo -n '{ "version": "' > lib/@codemirror/version.json
(cd node_modules/@codemirror/state && node -p "require('./package.json').version") | tr -d '\n' >> lib/@codemirror/version.json
echo '" }' >> lib/@codemirror/version.json
patch-codemirror:
cd lib/ && for P in codemirror-patches/*.patch; do echo " $$P"; cat $$P | patch --ignore-whitespace -p 0; done
fix-codemirror: sync-codemirror patch-codemirror version-codemirror
npx webpack --config ./pack/webpack-orga.config.cjs
bin/fix-scope cookshack
bin/fix-scope codemirror
bin/fix-scope codemirror/legacy-modes/mode
cd lib/@codemirror/ && find . -type f -name language-data.js | xargs sed -i "s/import('\([^']*\)')/import\('..\/\\1.js'\)/g"
cd lib/@codemirror/ && echo 'let bredHackImport = (x) => x.replace(/^(.*)$$/, "../$$1.js")' >> language-data.js
cd lib/@codemirror/ && sed -i "s/import(\([^)]\+[^\"']\))/import(bredHackImport(\\1))/g" language-data.js
#bin/fix-scope kittycad
bin/fix-scope lezer
bin/fix-scope marijn
bin/fix-scope replit
bin/fix-scope valtown
cd lib/@orgajs/ && find . -type f -name \*.js | xargs sed -i "s/^\(import .* from\) '\([^.'][^']*\)'.*/\\1 '..\/\\2.js';/g"
cd lib/@orgajs/ && find . -type f -name \*.js | xargs sed -i "s/ from '\@\([^']\+\)'.*/ from '..\/\@\\1.js';/g"
cp lib/@orgajs/index.js lib/@orgajs/lezer.js
for DIR in lib/@uiw/*; do find $$DIR -type f -name \*.js | xargs sed -i "s/^\(export .* from\) [\"']\(\.[^']*\)[\"'].*/\\1 '\\2.js';/g"; done
for DIR in lib/@uiw/*; do find $$DIR -type f -name \*.js | xargs sed -i "s/^\(import .* from\) [\"']\(\.[^']*\)[\"'].*/\\1 '\\2.js';/g"; done
for DIR in lib/@uiw/*; do find $$DIR -type f -name \*.js | xargs sed -i "s/^\(import .* from\) [\"']\([^.'][^']*\)[\"'].*/\\1 '..\/..\/\\2.js';/g"; done
echo "export * from './codemirror-themes/index.js'" > lib/@uiw/codemirror-themes.js
sed -i "s/^\(import .* from\) '\([^']\+\)'.*/\\1 '.\/\\2.js';/g" lib/lezer-elixir.js
sed -i "s/^\(import .* from\) '\([^']\+\)'.*/\\1 '.\/\\2.js';/g" lib/lezer-utils.js
sed -i "s/^\(import .* from\) '\([^']\+\)'.*/\\1 '.\/\\2.js';/g" lib/codemirror-lang-elixir.js
if [ -e node_modules/codemirror-lang-git-log ]; then sed -i "s/^\(import .* from\) '\([^']\+\)'.*/\\1 '.\/\\2.js';/g" lib/codemirror-lang-git-log.js; fi
sed -i "s/^\(import .* from\) '\([^']\+\)'.*/\\1 '.\/\\2.js';/g" lib/codemirror-lang-makefile.js
sed -i "s/^\import '\([^']\+\)';/import '.\/\\1.js';/g" lib/codemirror-lang-makefile.js
sed -i "s/var StyleModule = exports.StyleModule/export var StyleModule/g" lib/style-mod.js
sed -i "s/var \([^ ]\+\) = require('\([^']*\)');/import * as \\1 from '..\/\\2.js'/g" lib/@lezer/php.js
sed -i "s;Object.defineProperty(exports;//Object.defineProperty(exports;g" lib/@lezer/php.js
sed -i "s\exports.parser = parser;\export { parser };\g" lib/@lezer/php.js
fix-others: sync-others
sed -i "s/output.status = success ? 0 : 1;/output.status = success ? 0 : 1; output.installWasNeeded = installNeeded;/g" lib/check-dependencies.cjs
sed -i "s/function/export function/g" lib/fast-word-wrap.js
sed -i "s/module.exports/\/\/module.exports/g" lib/fast-word-wrap.js
sync-others:
cp node_modules/diff/lib/index.mjs lib/diff.js
cp node_modules/check-dependencies/lib/check-dependencies.js lib/check-dependencies.cjs
cp node_modules/color-blend/dist/index.modern.js lib/color-blend.js
cp node_modules/escape-string-regexp/index.js lib/escape-string-regexp.js
cp node_modules/fast-word-wrap/index.js lib/fast-word-wrap.js
cp node_modules/get-current-line/edition-es2022-esm/index.js lib/get-current-line.js
mkdir -p lib/typescript-language-server/lib/
cp node_modules/typescript-language-server/lib/cli.mjs lib/typescript-language-server/lib/cli.mjs
cp node_modules/typescript-language-server/package.json lib/typescript-language-server/package.json # cli.mjs reads version from here
mkdir -p lib/uuid/
cp node_modules/uuid/dist/esm-browser/* lib/uuid/
rm -rf lib/opencode
mkdir -p lib/opencode/v2/gen
cp node_modules/@opencode-ai/sdk/dist/process.js lib/opencode/process.js
cp node_modules/@opencode-ai/sdk/dist/error-interceptor.js lib/opencode/error-interceptor.js
cp node_modules/@opencode-ai/sdk/dist/v2/server.js lib/opencode/v2/server.js
sed -i "s/signal: options.signal,/signal: options.signal,\n cwd: options.config?.root,/" lib/opencode/v2/server.js
sed -i "s/proc.stderr?.on(\"data\", (chunk) => {/proc.stderr?.on(\"data\", (chunk) => {\n console.error(chunk.toString());/" lib/opencode/v2/server.js
sed -i "s/proc.stdout?.on(\"data\", (chunk) => {/proc.stdout?.on(\"data\", (chunk) => {\n console.log(chunk.toString());/" lib/opencode/v2/server.js
cp -r node_modules/@opencode-ai/sdk/dist/v2/gen lib/opencode/v2/
sync-codemirror:
rm -rf lib/@codemirror
rm -rf lib/@kittycad
rm -rf lib/@lezer
rm -rf lib/@markdoc
rm -rf lib/@marijn
rm -rf lib/@replit
rm -rf lib/@orgajs
rm -rf lib/@uiw
rm -rf lib/@babel
rm -rf lib/@valtown
mkdir -p lib/@kittycad
mkdir -p lib/@lezer
mkdir -p lib/@markdoc
mkdir -p lib/@marijn
mkdir -p lib/@replit
mkdir -p lib/@valtown
mkdir -p lib/@orgajs
mkdir -p lib/@uiw
mkdir -p lib/@babel/runtime/helpers/
bin/sync-scope cookshack
bin/sync-scope kittycad
# bad marijn
#bin/sync-scope marijn
cp node_modules/@marijn/find-cluster-break/src/index.js lib/@marijn/find-cluster-break.js
bin/sync-scope valtown
cp node_modules/globals/globals.json lib/globals.json
cp node_modules/@babel/runtime/helpers/esm/extends.js lib/@babel/runtime/helpers/extends.js
cp node_modules/lezer-elixir/dist/index.js lib/lezer-elixir.js
cp node_modules/lezer-utils/dist/pretty.js lib/lezer-utils.js
cp node_modules/codemirror-lang-elixir/dist/index.js lib/codemirror-lang-elixir.js
if [ -e node_modules/codemirror-lang-git-log ]; then cp node_modules/codemirror-lang-git-log/dist/index.js lib/codemirror-lang-git-log.js; fi
cp node_modules/codemirror-lang-makefile/dist/index.js lib/codemirror-lang-makefile.js
cp node_modules/@markdoc/markdoc/dist/index.mjs lib/@markdoc/markdoc.js
cp node_modules/@replit/codemirror-lang-csharp/dist/index.js lib/@replit/codemirror-lang-csharp.js
cp node_modules/@replit/codemirror-lang-nix/dist/index.js lib/@replit/codemirror-lang-nix.js
cp node_modules/@replit/codemirror-css-color-picker/dist/index.js lib/@replit/codemirror-css-color-picker.js
cp node_modules/@orgajs/cm-lang/index.js lib/@orgajs/codemirror-lang-org.js
cp node_modules/@orgajs/lezer/lib/*.js lib/@orgajs/
cp node_modules/@cookshack/eslint-config/dist/eslint-linter-browserify.mjs lib/eslint-linter-browserify.mjs
# cp -r node_modules/@codemirror/commands/dist/index.js lib/@codemirror/commands.js
# so next cmd passes
mkdir -p node_modules/@codemirror/legacy-modes/dist && echo > node_modules/@codemirror/legacy-modes/dist/index.js
bin/sync-scope codemirror
mkdir -p lib/@codemirror/legacy-modes/mode
cp node_modules/@codemirror/legacy-modes/mode/*.js lib/@codemirror/legacy-modes/mode/
for DIR in node_modules/@lezer/*; do cp $$DIR/dist/index.js lib/@lezer/$$(basename $$DIR).js; done
bin/fix-scope lezer
cp node_modules/style-mod/dist/style-mod.cjs lib/style-mod.js
cp node_modules/crelt/index.js lib/crelt.js
cp node_modules/w3c-keyname/index.js lib/w3c-keyname.js
cp node_modules/@lezer/php/dist/index.cjs lib/@lezer/php.js # .js is missing
for DIR in node_modules/@uiw/*; do mkdir -p lib/@uiw/$$(basename $$DIR)/; cp $$DIR/esm/*.js lib/@uiw/$$(basename $$DIR)/; done
gen-pngs:
inkscape --export-filename=img/logo.png --batch-process -w 256 -h 256 img/logo.svg
inkscape --export-filename=img/logom.png --batch-process -w 256 -h 256 img/logom.svg
sync-icons:
echo ERR maybe later
rm -rf lib/icon/
mkdir -p lib/icon/
find node_modules/@fluentui/svg-icons/icons/*_24_regular.svg | while read f; do cp $$f lib/icon/$$(basename $$f | sed -e 's/_24_regular.svg$$/.svg/g'); done
pack:
# npx webpack --config ./pack/pack.config.js
echo ERR in main.html now
release:
npm run make # FIX fails due to symlinks
jshint:
npx jshint --config=.jshint --reporter=unix *.mjs