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 5, 2022
2 parents 083979b + 1bb2fd8 commit 7fcfc1e
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 42 deletions.
12 changes: 10 additions & 2 deletions js/npm/rules.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//bzl/versioning:rules.bzl", "bump_on_change_test", "semver_version")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("//js/npm/yarn/lock:rules.bzl", "lockfile_minimize")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//js/api-extractor:rules.bzl", "api_extractor")
Expand Down Expand Up @@ -57,13 +58,20 @@ def npm_pkg(
publicTrimmedRollup = "public.d.ts",
)

copy_to_directory(
name = name + "_dir",
srcs = srcs + deps + [pkg_json_name, lockfile_name, "public.d.ts"],
replace_prefixes = {
"public.d.ts": "index.d.ts",
},
)

pkg_srcs = srcs
pkg_deps = deps + [pkg_json_name, lockfile_name]
pkg_npm(
name = name,
package_name = package_name,
srcs = pkg_srcs,
deps = pkg_deps,
deps = [name + "_dir"],
tgz = tgz,
visibility = visibility,
)
Expand Down
27 changes: 13 additions & 14 deletions ts/cmd/svgshot/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//ts:rules.bzl", "jest_test", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//:rules.bzl", "nodejs_binary")
load("//js/npm:rules.bzl", "npm_pkg")

Expand All @@ -12,11 +13,9 @@ ts_project(
srcs = [
"index.ts",
"lib.ts",
"svgshot_test.ts",
"run.ts"
],
deps = [
"@npm//@bazel/runfiles",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/svgo",
"@npm//@types/tmp",
Expand All @@ -27,17 +26,17 @@ ts_project(
],
)

nodejs_binary(
name = "svgshot",
args = [
"--inkscapeBin",
"$(location //cc/inkscape:bin)",
],
data = [
ts_project(
name = "tests_js",
srcs = ["svgshot_test.ts"],
deps = [
":project",
"//cc/inkscape:bin",
"@npm//@bazel/runfiles",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/tmp",
"@npm//tmp",
],
entry_point = "index.ts",
)

jest_test(
Expand All @@ -46,15 +45,15 @@ jest_test(
data = [
"//cc/inkscape:bin",
],
deps = [":project"],
deps = [":tests_js"],
)

npm_pkg(
name = "npm_pkg",
package_name = "svgshot",
srcs = ["README.md"] + glob(["docs/**/*"]),
api_lock = ".api.lock",
entry_point = "lib.ts",
entry_point = "index.ts",
major_version = "version/MAJOR",
minor_version = "version/MINOR",
patch_version = "version/PATCH",
Expand Down
20 changes: 2 additions & 18 deletions ts/cmd/svgshot/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
#!/usr/bin/env node

/**
* @fileoverview The main entry point for svgshot.
*
* Svgshot is separated out into a lib to allow easier testing.
*
* I wouldn't worry about it too much.
*/

import main from './lib';

main()
.catch(e => {
console.error(e);
process.exit(1);
})
.then(() => process.exit(0));
export * from './lib';
export { default } from './lib';
2 changes: 1 addition & 1 deletion ts/cmd/svgshot/package.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "svgshot",
"main": "index.js",
"bin": {
"svgshot": "index.js"
"svgshot": "run.js"
},
"repository": {
"type": "git",
Expand Down
18 changes: 18 additions & 0 deletions ts/cmd/svgshot/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

/**
* @fileoverview The main entry point for svgshot.
*
* Svgshot is separated out into a lib to allow easier testing.
*
* I wouldn't worry about it too much.
*/

import main from './lib';

main()
.catch(e => {
console.error(e);
process.exit(1);
})
.then(() => process.exit(0));
2 changes: 1 addition & 1 deletion ts/cmd/svgshot/svgshot_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import main from './lib';
import main from 'monorepo/ts/cmd/svgshot/lib';
import tmp from 'tmp';
import fs from 'fs/promises';
import { runfiles } from '@bazel/runfiles';
Expand Down
7 changes: 2 additions & 5 deletions ts/do-sync/testing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ package(default_visibility = [

ts_project(
name = "project",
srcs = glob(["**/*.ts"]) + [":npm_pkg"],
srcs = glob(["**/*.ts"]),
deps = [
"@npm//@types/jest",
"@npm//@types/sharp",
"@npm//sharp",
"//ts/do-sync"
],
)

js_library(
name = "npm_pkg",
deps = ["//ts/do-sync:npm_pkg"],
)

jest_test(
name = "tests",
Expand Down
2 changes: 1 addition & 1 deletion ts/do-sync/testing/doSync_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { doSync, JSONObject } from 'monorepo/ts/do-sync/npm_pkg';
import { doSync, JSONObject } from 'monorepo/ts/do-sync';
import sharpT from 'sharp';

const pixel =
Expand Down

0 comments on commit 7fcfc1e

Please sign in to comment.