mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Merge pull request #1408 from ankitects/root-node
move node_modules into root folder [action required]
This commit is contained in:
commit
26e2941950
18 changed files with 45 additions and 45 deletions
|
@ -1 +1 @@
|
||||||
ts/node_modules
|
node_modules
|
||||||
|
|
|
@ -11,7 +11,7 @@ BAZEL="bazel --output_user_root=/state/bazel --output_base=/state/bazel/anki"
|
||||||
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore --disk_cache=/state/bazel/disk --repository_cache=/state/bazel/repo"
|
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore --disk_cache=/state/bazel/disk --repository_cache=/state/bazel/repo"
|
||||||
|
|
||||||
# move existing node_modules into tree
|
# move existing node_modules into tree
|
||||||
test -e /state/node_modules && mv /state/node_modules ts/
|
test -e /state/node_modules && mv /state/node_modules .
|
||||||
|
|
||||||
$BAZEL build $BUILDARGS ...
|
$BAZEL build $BUILDARGS ...
|
||||||
|
|
||||||
|
@ -26,4 +26,4 @@ python scripts/copyright_headers.py
|
||||||
|
|
||||||
echo "--- Cleanup"
|
echo "--- Cleanup"
|
||||||
# if tests succeed, back up node_modules folder
|
# if tests succeed, back up node_modules folder
|
||||||
mv ts/node_modules /state/
|
mv node_modules /state/
|
||||||
|
|
|
@ -7,7 +7,7 @@ BAZEL="bazel --output_user_root=~/bazel --output_base=~/bazel/anki"
|
||||||
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore"
|
BUILDARGS="--config=ci --experimental_convenience_symlinks=ignore"
|
||||||
|
|
||||||
# move existing node_modules into tree
|
# move existing node_modules into tree
|
||||||
test -e ~/node_modules && mv ~/node_modules ts/
|
test -e ~/node_modules && mv ~/node_modules .
|
||||||
|
|
||||||
$BAZEL build $BUILDARGS ...
|
$BAZEL build $BUILDARGS ...
|
||||||
|
|
||||||
|
@ -16,4 +16,4 @@ $BAZEL test $BUILDARGS ...
|
||||||
|
|
||||||
echo "--- Cleanup"
|
echo "--- Cleanup"
|
||||||
# if tests succeed, back up node_modules folder
|
# if tests succeed, back up node_modules folder
|
||||||
mv ts/node_modules ~/
|
mv node_modules ~/
|
||||||
|
|
|
@ -3,7 +3,7 @@ set BAZEL=\bazel\bazel.exe --output_user_root=\bazel\ankici --output_base=\bazel
|
||||||
set BUILDARGS=--config=ci
|
set BUILDARGS=--config=ci
|
||||||
|
|
||||||
if exist \bazel\node_modules (
|
if exist \bazel\node_modules (
|
||||||
move \bazel\node_modules ts\node_modules
|
move \bazel\node_modules .\node_modules
|
||||||
)
|
)
|
||||||
|
|
||||||
:: rollup may fail on the first build, so we build once without checking return code
|
:: rollup may fail on the first build, so we build once without checking return code
|
||||||
|
@ -37,4 +37,4 @@ IF %ERRORLEVEL% NEQ 0 exit /B 1
|
||||||
@REM echo Import succesful.
|
@REM echo Import succesful.
|
||||||
|
|
||||||
echo --- Cleanup
|
echo --- Cleanup
|
||||||
move ts\node_modules \bazel\node_modules
|
move node_modules \bazel\node_modules
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ target
|
||||||
user.bazelrc
|
user.bazelrc
|
||||||
.dmypy.json
|
.dmypy.json
|
||||||
rust-project.json
|
rust-project.json
|
||||||
|
node_modules
|
||||||
|
|
|
@ -33,5 +33,7 @@ pkg_tar(
|
||||||
tags = ["manual"],
|
tags = ["manual"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# for version info
|
exports_files([
|
||||||
exports_files(["defs.bzl"])
|
"defs.bzl",
|
||||||
|
"package.json",
|
||||||
|
])
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
workspace(
|
workspace(
|
||||||
name = "ankidesktop",
|
name = "ankidesktop",
|
||||||
managed_directories = {"@npm": [
|
managed_directories = {"@npm": [
|
||||||
"ts/node_modules",
|
"node_modules",
|
||||||
]},
|
]},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
6
defs.bzl
6
defs.bzl
|
@ -43,12 +43,12 @@ def setup_deps():
|
||||||
python_runtime = "@python//:python",
|
python_runtime = "@python//:python",
|
||||||
)
|
)
|
||||||
|
|
||||||
node_repositories(package_json = ["@ankidesktop//ts:package.json"])
|
node_repositories(package_json = ["@ankidesktop//:package.json"])
|
||||||
|
|
||||||
yarn_install(
|
yarn_install(
|
||||||
name = "npm",
|
name = "npm",
|
||||||
package_json = "@ankidesktop//ts:package.json",
|
package_json = "@ankidesktop//:package.json",
|
||||||
yarn_lock = "@ankidesktop//ts:yarn.lock",
|
yarn_lock = "@ankidesktop//:yarn.lock",
|
||||||
)
|
)
|
||||||
|
|
||||||
sass_repositories()
|
sass_repositories()
|
||||||
|
|
|
@ -181,7 +181,7 @@ of `use` statements.
|
||||||
|
|
||||||
The Bazel build products will make RA start up slowly out of the box. For a much
|
The Bazel build products will make RA start up slowly out of the box. For a much
|
||||||
nicer experience, add each of the bazel-* folders to Rust Analyzer's excludeDirs
|
nicer experience, add each of the bazel-* folders to Rust Analyzer's excludeDirs
|
||||||
settings, and ts/node_modules. Wildcards don't work unfortunately. Then adjust
|
settings, and node_modules. Wildcards don't work unfortunately. Then adjust
|
||||||
VS Code's "watcher exclude", and add `**/bazel-*`.
|
VS Code's "watcher exclude", and add `**/bazel-*`.
|
||||||
|
|
||||||
After running 'code' from the project root, it may take a minute or two to be
|
After running 'code' from the project root, it may take a minute or two to be
|
||||||
|
@ -203,12 +203,12 @@ Recording also requires `lame` to be in your system path.
|
||||||
## Build errors and cleaning
|
## Build errors and cleaning
|
||||||
|
|
||||||
If you get errors with @npm and node_modules in the message, try deleting the
|
If you get errors with @npm and node_modules in the message, try deleting the
|
||||||
ts/node_modules folder.
|
node_modules folder.
|
||||||
|
|
||||||
Unlike the old Make system, a "clean build" should almost never be required
|
Unlike the old Make system, a "clean build" should almost never be required
|
||||||
unless you are debugging issues with the build system. But if you need to get
|
unless you are debugging issues with the build system. But if you need to get
|
||||||
things to a fresh state, you can run `bazel clean --expunge`. Afte doing so,
|
things to a fresh state, you can run `bazel clean --expunge`. After doing so,
|
||||||
make sure you remove the ts/node_modules folder, or subsequent build commands
|
make sure you remove the node_modules folder, or subsequent build commands
|
||||||
will fail with a "no such file or directory node_modules/anki" message.
|
will fail with a "no such file or directory node_modules/anki" message.
|
||||||
|
|
||||||
## Tracing build problems
|
## Tracing build problems
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fix": "prettier --write */*.ts */*.svelte",
|
"fix": "prettier --write */*.ts */*.svelte",
|
||||||
"postinstall": "patch-package"
|
"postinstall": "patch-package --patch-dir ts/patches"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluent/bundle": "^0.17.0",
|
"@fluent/bundle": "^0.17.0",
|
|
@ -18,7 +18,7 @@ nonstandard_header = {
|
||||||
ignored_folders = [
|
ignored_folders = [
|
||||||
"bazel-",
|
"bazel-",
|
||||||
"qt/forms",
|
"qt/forms",
|
||||||
"ts/node_modules",
|
"node_modules",
|
||||||
]
|
]
|
||||||
|
|
||||||
if not os.path.exists("WORKSPACE"):
|
if not os.path.exists("WORKSPACE"):
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SASS_PATH=$(pwd)/bazel-bin ts/node_modules/.bin/svelte-check --workspace ts
|
SASS_PATH=ts/sass:$(pwd)/bazel-bin/ts/sass \
|
||||||
|
node_modules/.bin/svelte-check \
|
||||||
|
--workspace ts
|
||||||
|
|
|
@ -17,7 +17,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
$: mathjaxElement = activeImage.parentElement!;
|
$: mathjaxElement = activeImage.parentElement!;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ButtonGroup size={1.6} wrap={false} reverse={isRtl}>
|
<ButtonGroup size={1.6} wrap={false}>
|
||||||
|
{#if isRtl}
|
||||||
|
<!-- fixme -->
|
||||||
|
{/if}
|
||||||
<ButtonGroupItem>
|
<ButtonGroupItem>
|
||||||
<IconButton
|
<IconButton
|
||||||
tooltip={tr.editingMathjaxInline()}
|
tooltip={tr.editingMathjaxInline()}
|
||||||
|
|
|
@ -3,17 +3,6 @@ load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "declaratio
|
||||||
load("@io_bazel_rules_sass//:defs.bzl", "SassInfo")
|
load("@io_bazel_rules_sass//:defs.bzl", "SassInfo")
|
||||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||||
|
|
||||||
def _get_dep_sources(dep):
|
|
||||||
if SassInfo in dep:
|
|
||||||
return dep[SassInfo].transitive_sources
|
|
||||||
elif DeclarationInfo in dep:
|
|
||||||
return dep[DeclarationInfo].transitive_declarations
|
|
||||||
else:
|
|
||||||
return []
|
|
||||||
|
|
||||||
def _get_sources(deps):
|
|
||||||
return depset([], transitive = [_get_dep_sources(dep) for dep in deps])
|
|
||||||
|
|
||||||
def _svelte(ctx):
|
def _svelte(ctx):
|
||||||
args = ctx.actions.args()
|
args = ctx.actions.args()
|
||||||
args.use_param_file("@%s", use_always = True)
|
args.use_param_file("@%s", use_always = True)
|
||||||
|
@ -25,18 +14,19 @@ def _svelte(ctx):
|
||||||
args.add(ctx.outputs.css.path)
|
args.add(ctx.outputs.css.path)
|
||||||
args.add(ctx.var["BINDIR"])
|
args.add(ctx.var["BINDIR"])
|
||||||
args.add(ctx.var["GENDIR"])
|
args.add(ctx.var["GENDIR"])
|
||||||
|
args.add_all(ctx.files._shims)
|
||||||
|
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
execution_requirements = {"supports-workers": "1"},
|
execution_requirements = {"supports-workers": "1"},
|
||||||
executable = ctx.executable._svelte_bin,
|
executable = ctx.executable._svelte_bin,
|
||||||
outputs = [ctx.outputs.mjs, ctx.outputs.dts, ctx.outputs.css],
|
outputs = [ctx.outputs.mjs, ctx.outputs.dts, ctx.outputs.css],
|
||||||
inputs = [ctx.file.entry_point],
|
inputs = [ctx.file.entry_point] + ctx.files._shims,
|
||||||
mnemonic = "Svelte",
|
mnemonic = "Svelte",
|
||||||
arguments = [args],
|
arguments = [args],
|
||||||
)
|
)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
declaration_info(depset([ctx.outputs.dts]), deps = []),
|
declaration_info(depset([ctx.outputs.dts]), deps = [ctx.attr._shims]),
|
||||||
]
|
]
|
||||||
|
|
||||||
svelte = rule(
|
svelte = rule(
|
||||||
|
@ -48,6 +38,10 @@ svelte = rule(
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "host",
|
cfg = "host",
|
||||||
),
|
),
|
||||||
|
"_shims": attr.label(
|
||||||
|
default = Label("@npm//svelte2tsx:svelte2tsx__typings"),
|
||||||
|
allow_files = True,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
outputs = {
|
outputs = {
|
||||||
"mjs": "%{name}.svelte.mjs",
|
"mjs": "%{name}.svelte.mjs",
|
||||||
|
@ -82,7 +76,6 @@ def svelte_check(name = "svelte_check", srcs = []):
|
||||||
"--fail-on-hints",
|
"--fail-on-hints",
|
||||||
],
|
],
|
||||||
data = [
|
data = [
|
||||||
"//ts:tsconfig_bin",
|
|
||||||
"@npm//sass",
|
"@npm//sass",
|
||||||
] + srcs,
|
] + srcs,
|
||||||
env = {"SASS_PATH": "ts/sass"},
|
env = {"SASS_PATH": "ts/sass"},
|
||||||
|
|
|
@ -90,8 +90,8 @@ const languageServiceHost: ts.LanguageServiceHost = {
|
||||||
|
|
||||||
const languageService = ts.createLanguageService(languageServiceHost);
|
const languageService = ts.createLanguageService(languageServiceHost);
|
||||||
|
|
||||||
function compile(tsPath: string) {
|
function compile(tsPath: string, tsLibs: string[]) {
|
||||||
parsedCommandLine.fileNames = [tsPath];
|
parsedCommandLine.fileNames = [tsPath, ...tsLibs];
|
||||||
const program = languageService.getProgram()!;
|
const program = languageService.getProgram()!;
|
||||||
const tsHost = ts.createCompilerHost(parsedCommandLine.options);
|
const tsHost = ts.createCompilerHost(parsedCommandLine.options);
|
||||||
const createdFiles = {};
|
const createdFiles = {};
|
||||||
|
@ -124,8 +124,8 @@ function readFile(file) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeDts(tsPath, dtsPath) {
|
async function writeDts(tsPath, dtsPath, tsLibs) {
|
||||||
const dtsSource = compile(tsPath);
|
const dtsSource = compile(tsPath, tsLibs);
|
||||||
await writeFile(dtsPath, dtsSource);
|
await writeFile(dtsPath, dtsSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ async function writeJs(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function compileSvelte(args) {
|
async function compileSvelte(args) {
|
||||||
const [sveltePath, mjsPath, dtsPath, cssPath, binDir, genDir] = args;
|
const [sveltePath, mjsPath, dtsPath, cssPath, binDir, genDir, ...tsLibs] = args;
|
||||||
const svelteSource = (await readFile(sveltePath)) as string;
|
const svelteSource = (await readFile(sveltePath)) as string;
|
||||||
|
|
||||||
const mockTsPath = sveltePath + ".tsx";
|
const mockTsPath = sveltePath + ".tsx";
|
||||||
writeTs(svelteSource, sveltePath, mockTsPath);
|
writeTs(svelteSource, sveltePath, mockTsPath);
|
||||||
await writeDts(mockTsPath, dtsPath);
|
await writeDts(mockTsPath, dtsPath, tsLibs);
|
||||||
await writeJs(svelteSource, sveltePath, mjsPath, cssPath, binDir, genDir);
|
await writeJs(svelteSource, sveltePath, mjsPath, cssPath, binDir, genDir);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
],
|
],
|
||||||
// uncomment for building with tsc directly
|
// uncomment for building with tsc directly
|
||||||
// "outDir": "dist",
|
// "outDir": "dist",
|
||||||
// "rootDir": "..",
|
"rootDir": "..",
|
||||||
"rootDir": ".",
|
|
||||||
"rootDirs": [
|
"rootDirs": [
|
||||||
".",
|
".",
|
||||||
// for VS code
|
// for VS code
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
./node_modules/.bin/license-checker-rseidelsohn --production --json \
|
cd .. && ./node_modules/.bin/license-checker-rseidelsohn --production --json \
|
||||||
--excludePackages anki --relativeLicensePath \
|
--excludePackages anki --relativeLicensePath \
|
||||||
--relativeModulePath > licenses.json
|
--relativeModulePath > ts/licenses.json
|
||||||
|
|
Loading…
Reference in a new issue