Skip to content

Commit

Permalink
Merge branch 'main' into versioned
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 9, 2022
2 parents f2acdd8 + b9bd996 commit 6ca39be
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
5.0.0-pre.20210913.1
6.0.0-pre.20220720.3

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
with:
node-version: '16'
- name: Restore bazel cache
uses: actions/[email protected].5
uses: actions/[email protected].6
env:
cache-name: bazel-cache
with:
Expand All @@ -79,7 +79,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'
node-version: '16'
- name: Restore bazel cache
uses: actions/[email protected].5
uses: actions/[email protected].6
env:
cache-name: bazel-cache
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
node-version: '16'
- name: Restore bazel cache
uses: actions/[email protected].5
uses: actions/[email protected].6
env:
cache-name: bazel-cache
with:
Expand All @@ -45,7 +45,7 @@ jobs:
# Needed to allow an action to trigger another action.
token: ${{ secrets.GH_PAT }}
- name: Restore bazel cache
uses: actions/[email protected].5
uses: actions/[email protected].6
env:
cache-name: bazel-cache
with:
Expand Down
12 changes: 4 additions & 8 deletions .swcrc → .swcrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"$schema": "https://json.schemastore.org/swcrc.json",
"jsc": {
"target": "es2022",
"parser": {
"tsx": true,
"syntax": "typescript",
"jsx": true,
"numericSeparator": false,
"classPrivateProperty": false,
"privateMethod": false,
"classProperty": false,
"functionBind": false,
"decorators": false,
"decoratorsBeforeExport": false
"decorators": false
},
"transform": {
"react": {
Expand Down
3 changes: 1 addition & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ exports_files(
".eslintrc.json",
"css_loader.d.ts",
"yarn.lock",
".swcrc",
],
visibility = ["//visibility:public"],
)
Expand All @@ -57,5 +56,5 @@ esbuild_config(

copy_to_bin(
name = "swcrc",
srcs = [".swcrc"],
srcs = [".swcrc.json"],
)
3 changes: 0 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ bind(
workspace(
# How this workspace would be referenced with absolute labels from another workspace
name = "monorepo",
# Map the @npm bazel workspace to the node_modules directory.
# This lets Bazel use the same node_modules as other local tooling.
managed_directories = {"@npm": ["node_modules"]},
)

load("//bzl:deps.bzl", "fetch_dependencies")
Expand Down
1 change: 1 addition & 0 deletions js/npm/package_json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ts_project(
visibility = ["//:__subpackages__"],
deps = [
"@npm//@bazel/runfiles",
"@npm//@schemastore/package",
"@npm//@types/node",
"@npm//commander",
],
Expand Down
12 changes: 6 additions & 6 deletions js/npm/package_json/gen_pkgjson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs/promises';
import { Command } from 'commander';
import { JSONSchemaForNPMPackageJsonFiles as packageJson } from '@schemastore/package';

const depTypes = {
skip: (v: string) => v === '@bazel/runfiles',
Expand Down Expand Up @@ -65,14 +66,13 @@ const main = async () => {
);

const pkg_json_buf = await fs.readFile(opts.base);
const pkg_json: {
devDependencies: Record<string, string>;
dependencies: Record<string, string>;
} = JSON.parse(pkg_json_buf.toString());

// this could be less strict, but it resulted in crashes
const pkg_json: packageJson = JSON.parse(pkg_json_buf.toString());

const all_deps = new Map([
...Object.entries(pkg_json.dependencies),
...Object.entries(pkg_json.devDependencies),
...Object.entries(pkg_json.dependencies ?? []),
...Object.entries(pkg_json.devDependencies ?? []),
]);

const our_deps = [...all_deps]
Expand Down
21 changes: 20 additions & 1 deletion js/npm/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//js/api-extractor:rules.bzl", "api_extractor")
load("//js/npm/package_json:rules.bzl", "package_json")

def _exclude_all_external_rule(ctx):
return DefaultInfo(files = depset([
file
for file in ctx.files.srcs
if file.owner.workspace_name == ""
]))

exclude_all_external_rule = rule(
implementation = _exclude_all_external_rule,
attrs = {
"srcs": attr.label_list(allow_files = True),
},
)

def npm_pkg(
name,
package_name,
Expand Down Expand Up @@ -84,11 +98,16 @@ def npm_pkg(
visibility = visibility,
)

exclude_all_external_rule(
name = "version_lock_files",
srcs = pkg_srcs + pkg_deps,
)

# Test that ensures at least a minor bump happens when
# a change in files occurs.
bump_on_change_test(
name = "version_lock",
srcs = pkg_srcs + pkg_deps,
srcs = [":version_lock_files"],
version = minor_version,
run_on_main = test_version_on_main,
version_lock = version_lock,
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@
"@pulumi/aws": "^4.0.0",
"@pulumi/awsx": "^0.32.0",
"@pulumi/pulumi": "^3.37.2",
"@schemastore/package": "^0.0.6",
"@swc/cli": "^0.1.57",
"@testing-library/react": "^13.3.0",
"@types/cross-spawn": "^6.0.2",
"@types/d3-axis": "^3.0.1",
"@types/d3-scale": "^4.0.2",
"@types/jest": "^28.1.6",
"@types/mime": "^3.0.1",
"@types/node": "^18.6.4",
"@types/react": "18.0.15",
"@types/react": "18.0.16",
"@types/react-dom": "^18.0.6",
"@types/sharp": "^0.30.4",
"@types/sharp": "^0.30.5",
"@types/svgo": "^2.6.3",
"@types/tmp": "^0.2.3",
"@types/uuid": "^8.3.4",
Expand Down Expand Up @@ -63,7 +65,7 @@
"module-alias": "^2.2.2",
"patch-package": "^6.4.7",
"prettier": "^2.7.1",
"puppeteer": "^16.0.0",
"puppeteer": "^16.1.0",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.3.0",
Expand All @@ -90,6 +92,5 @@
"fix": "yarn run bazelisk run //:fix",
"dev": "yarn run ibazel --run_output --run_output_interactive=false test //...",
"pr": "gh pr create -f; gh pr merge -md --auto"
},
"dependencies": {}
}
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ yamllint==1.27.1
# via -r requirements.in

# The following packages are considered to be unsafe in a requirements file:
setuptools==63.4.1
setuptools==63.4.2
# via yamllint
9 changes: 3 additions & 6 deletions ts/math/vec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ export interface Vector<I extends number = number, T = number>
length: I;
}

type mapFn<I extends number, T> = <U>(
callbackFn: (value: T, index: number, array: Vector<I, T>) => U,
thisArg?: unknown
) => Vector<I, U>;

/**
* Map a Vector, returning a new Vector.
*/
export const map: <I extends number, T, U>(
vec: Vector<I, T>,
callbackFn: (value: T, index: number, array: Vector<I, T>) => U
) => Vector<I, U> = (vec, c) => {
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
) => Vector<I, U> = (vec, c) => (vec.map as mapFn<any, any>)(c);
return vec.map(c as any) as any;
};

/**
* Map an Iterable, returning a new Iterable.
Expand Down
13 changes: 6 additions & 7 deletions ts/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ def ts_project(name, visibility = None, deps = [], ignores_lint = [], resolve_js
srcs = srcs,
tsconfig = tsconfig,
# swc injects this
# uncomment these one day
#deps = deps + ["@npm//regenerator-runtime"],
#transpiler = partial.make(
# swc_transpiler,
# swcrc = "//:swcrc",
#),
deps = deps,
deps = deps + ["@npm//regenerator-runtime"],
transpiler = partial.make(
swc_transpiler,
swcrc = "//:swcrc",
source_maps = "true",
),
preserve_jsx = preserve_jsx,
resolve_json_module = resolve_json_module,
root_dir = root_dir,
Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
"rootDirs": ["bazel-out/k8-fastbuild/bin"],
"paths": {
"monorepo/*": [
"./*", "./monorepo/*", "bazel-out/k8-fastbuild/bin/monorepo/*"]
"./*",
"./monorepo/*",
"bazel-out/k8-fastbuild/bin/monorepo/*"
]
}
},
"exclude": ["node_modules", "dist", "external"]
Expand Down
Loading

0 comments on commit 6ca39be

Please sign in to comment.