-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscripts.ts
119 lines (112 loc) · 3.69 KB
/
scripts.ts
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
import meow from 'meow';
import shellac from 'shellac';
import langs from './build-languages';
const cli = meow({});
const services = ['typescript', 'css', 'json', 'html'];
switch (cli.input[0]) {
case 'copy-workers':
shellac`
$ git restore worker/package.json themes/package.json package.json
$ mkdir -p dist/workers
$ mkdir -p public/workers
$ mkdir -p dist/css
$ cp public/style.css dist/css/style.css
$ for x in .next/static/workers/*.monaco.worker.js;do cp $x "dist/workers/\${x##.next/static/workers/}";done
$ for x in .next/static/workers/*.monaco.worker.js;do cp $x "public/workers/\${x##.next/static/workers/}";done
`;
break;
case 'clean':
shellac`
$ rm -rf dist
`;
break;
case 'build':
shellac`
$$ rm -rf src/monaco/version.ts
$$ echo "export default '${cli.pkg.version}'" > src/monaco/utils/version.ts
$$ yarn script clean
$$ yarn next build
$$ yarn pkger build
$$ yarn script build:languages
$$ yarn script copy-workers
`;
break;
case 'build:plugins':
shellac`
$$ rm -rf .garage
$$ yarn tsup ${services
.map(
(languageService) =>
`./node_modules/monaco-${languageService}/release/esm/monaco.contribution.js`
)
.join(' ')} ${Object.keys(langs)
.map(
(lang) =>
`./node_modules/monaco-languages/release/esm/${langs[lang]}.js`
)
.join(
' '
)} --format iife --out-dir ./.garage/languages --external monaco-editor-core --external monaco-editor --legacy-output --minify
`;
case 'build:languages':
shellac`
$$ yarn patch-package
$$ rm -rf .garage
$$ mkdir -p .garage
$$ yarn tsup ${services
.map(
(languageService) =>
`./node_modules/monaco-${languageService}/release/esm/monaco.contribution.js`
)
.join(' ')} ${Object.keys(langs)
.map(
(lang) =>
`./node_modules/monaco-languages/release/esm/${langs[lang]}.js`
)
.join(
' '
)} --format iife --out-dir ./.garage/languages --external monaco-editor-core --external monaco-editor --legacy-output --minify
$$ rm -rf public/languages
$$ mkdir -p public/languages
$$ rm -rf dist/languages
$$ mkdir -p dist/languages
$$ ${Object.keys(langs)
.map(
(lang) =>
`cp .garage/languages/iife/monaco-languages/release/esm/${
langs[lang]
}.js public/languages/${langs[lang]
.split('/')[1]
.replace('.contribution', '.basic')}.js`
)
.join(' && ')}
$$ ${services
.map(
(languageService) =>
`cp .garage/languages/iife/monaco-${languageService}/release/esm/monaco.contribution.js public/languages/${languageService}.service.js`
)
.join(' && ')}
$$ ${Object.keys(langs)
.map(
(lang) =>
`cp .garage/languages/iife/monaco-languages/release/esm/${
langs[lang]
}.js dist/languages/${langs[lang]
.split('/')[1]
.replace('.contribution', '.basic')}.js`
)
.join(' && ')}
$$ ${services
.map(
(languageService) =>
`cp .garage/languages/iife/monaco-${languageService}/release/esm/monaco.contribution.js dist/languages/${languageService}.service.js`
)
.join(' && ')}`;
}
// $$ cp build/languages/${cli.flags.language}.global.js dist/plugins/${
// cli.flags.language
// }.monaco.plugin.js
// $$ cp build/languages/${cli.flags.language}.global.js public/plugins/${
// cli.flags.language
// }.monaco.plugin.js
// const languages = {};