Skip to content

Commit

Permalink
bsb test
Browse files Browse the repository at this point in the history
  • Loading branch information
shanewilson committed May 24, 2017
1 parent bae7eb6 commit 7b75861
Show file tree
Hide file tree
Showing 73 changed files with 328 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
src/modules/create-knit-app/template
lib
dist
build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ coverage
# build folders
build
dist
lib/bs
/lib

# OS
.DS_Store
14 changes: 14 additions & 0 deletions .merlin
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
####{BSB GENERATED: NO EDIT
FLG -ppx /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/bsppx.exe
S /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/lib/ocaml
B /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/lib/ocaml
FLG -nostdlib -bs-cross-module-opt -bs-gen-tds -no-alias-deps -color always -w -40+6+7+27+32..39+44+45
S src/modules
B lib/bs/src/modules
S src/modules/@knit/read-pkg
B lib/bs/src/modules/@knit/read-pkg
S src/modules/@knit/path-join
B lib/bs/src/modules/@knit/path-join
S src/modules/@knit/is-scoped
B lib/bs/src/modules/@knit/is-scoped
####BSB GENERATED: NO EDIT}
21 changes: 21 additions & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "beep",
"sources": [
{
"dir": "src/modules",
"subdirs": [
{"dir": "@knit/is-scoped"},
{"dir": "@knit/path-join"},
{"dir": "@knit/read-pkg"}
]
}
],
"package-specs": [
"commonjs"
],
"bsc-flags": [
"-bs-cross-module-opt",
"-bs-gen-tds"
],
"generate-merlin": true
}
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
},
"scripts": {
"precommit": "lint-staged",
"copy": "rm -rf dist && rm -rf build && yarn knit -- copy --ignore-path=@knit/**/{__mocks__,__tests__,*.js}",
"copy": "rm -rf dist && rm -rf build && yarn knit -- copy --ignore-path=@knit/**/{__mocks__,__tests__,bs,*.js,*.re,}",
"build-lib": "NODE_ENV=production babel src/modules/ -d dist/ --ignore __mocks__,__tests__,jest,create",
"build-cjs": "NODE_ENV=production yarn knit -- exec --concurrently --scope modified --include=@knit --exclude=jest -- babel . -d ROOT_DIR/dist/KNIT_MODULE_NAME --ignore __mocks__,__tests__,jest,create",
"build-packages": "yarn copy && yarn build-cjs && yarn knit -- stitch --scope modified",
"build-bsb": "NODE_ENV=production yarn knit -- exec --concurrently --include=is-scoped path-join read-pkg -- bsb",
"build-bsb-w": "NODE_ENV=production yarn knit -- exec --concurrently --include=is-scoped path-join read-pkg -- bsb -w",
"build-packages": "yarn build-bsb && yarn copy && yarn build-cjs && yarn knit -- stitch --scope modified",
"version": "yarn knit -- exec --scope modified -- npm version --no-git-tag-version $npm_package_version && git add .",
"publish-packages": "yarn knit -- exec --scope unpublished --working-dir build -- npm publish",
"knit": "babel-node src/modules/@knit/knit/bin/cli.js",
Expand Down Expand Up @@ -109,6 +111,7 @@
"babel-plugin-array-includes": "2.0.3",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"bs-platform": "1.7.3",
"eslint": "^3.16.1",
"eslint-config-google": "0.7.1",
"eslint-config-prettier": "2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/@knit/find-dependencies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { TPkgJson, TPkgJsonDeps } from "@knit/needle";

import depcheck from "@knit/depcheck";
import pathJoin from "@knit/path-join";
import { pathJoin } from "@knit/path-join";
import readPkg from "@knit/read-pkg";

export type TModules = Array<string>;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/@knit/find-modified-packages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { TModules } from "@knit/knit-core";
import execa from "execa";

import { makeDependencyMap } from "@knit/find-dependencies";
import isScoped from "@knit/is-scoped";
import { isScoped } from "@knit/is-scoped";

type TResolveCascadingUpdates = (
modules: TModules,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/@knit/find-packages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import fs from "fs-extra";

import isScoped from "@knit/is-scoped";
import pathJoin from "@knit/path-join";
import { isScoped } from "@knit/is-scoped";
import { pathJoin } from "@knit/path-join";
import getPackageFromDir from "@knit/get-package-from-dir";
import readPkg from "@knit/read-pkg";

Expand Down
3 changes: 3 additions & 0 deletions src/modules/@knit/is-scoped/IsScoped.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*let isScoped package => package.[0] === '@';*/
let isScoped (package: string) :Js.boolean =>
Js.Boolean.to_js_boolean (Js.String.get package 0 === "@");
2 changes: 1 addition & 1 deletion src/modules/@knit/is-scoped/__tests__/unit.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const is = require("..");
import { isScoped as is } from "..";

describe("isScoped", () => {
it("knows if package is scoped", () => {
Expand Down
11 changes: 11 additions & 0 deletions src/modules/@knit/is-scoped/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@knit/is-scoped",
"sources": ".",
"package-specs": [
"commonjs"
],
"bsc-flags": [
"-bs-cross-module-opt"
],
"generate-merlin": false
}
2 changes: 1 addition & 1 deletion src/modules/@knit/is-scoped/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
type TIsScoped = (m: string) => boolean;
const isScoped: TIsScoped = module => module[0] === "@";

export default isScoped;
export { isScoped };
Binary file added src/modules/@knit/is-scoped/lib/bs/.bsbuild
Binary file not shown.
Binary file added src/modules/@knit/is-scoped/lib/bs/.bsdeps
Binary file not shown.
Binary file added src/modules/@knit/is-scoped/lib/bs/.ninja_deps
Binary file not shown.
6 changes: 6 additions & 0 deletions src/modules/@knit/is-scoped/lib/bs/.ninja_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ninja log v5
0 99 0 IsScoped.mlast 9af5b4338cc28f52
99 111 0 IsScoped.mlast.d 6644a125cf832a46
0 16 0 IsScoped.cmj 3c1c3e96297ced90
0 16 0 /Users/swilson/Documents/Development/js/knitjs/knit/src/modules/@knit/is-scoped/lib/js/IsScoped.js 3c1c3e96297ced90
0 16 0 IsScoped.cmi 3c1c3e96297ced90
1 change: 1 addition & 0 deletions src/modules/@knit/is-scoped/lib/bs/.sourcedirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Binary file added src/modules/@knit/is-scoped/lib/bs/IsScoped.cmi
Binary file not shown.
Binary file added src/modules/@knit/is-scoped/lib/bs/IsScoped.cmj
Binary file not shown.
Binary file added src/modules/@knit/is-scoped/lib/bs/IsScoped.cmt
Binary file not shown.
Binary file added src/modules/@knit/is-scoped/lib/bs/IsScoped.mlast
Binary file not shown.
1 change: 1 addition & 0 deletions src/modules/@knit/is-scoped/lib/bs/IsScoped.mlast.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IsScoped.cmj :
30 changes: 30 additions & 0 deletions src/modules/@knit/is-scoped/lib/bs/build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ninja_required_version = 1.5.1
bs_package_flags = -bs-package-name @knit/is-scoped
src_root_dir = /Users/swilson/Documents/Development/js/knitjs/knit/src/modules/@knit/is-scoped
bsc = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/bsc.exe
bsdep = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/bsb_helper.exe
ocamllex = ocamllex.opt
bsc_flags = -nostdlib -I /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/lib/ocaml -bs-cross-module-opt -no-alias-deps -color always -w -40+6+7+27+32..39+44+45
ppx_flags =
bs_package_includes =
bs_package_dev_includes =
refmt = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/refmt.exe
reason_react_jsx =
refmt_flags = --print binary
bsb_dir_group = 0
bsc_lib_includes = -I .
rule build_ast_and_deps_from_reason_impl
command = ${bsc} -pp "${refmt} ${refmt_flags}" ${reason_react_jsx} ${ppx_flags} ${bsc_flags} -c -o ${out} -bs-syntax-only -bs-binary-ast -impl ${in}
description = Building ${out}
build IsScoped.mlast : build_ast_and_deps_from_reason_impl $src_root_dir/IsScoped.re
rule build_deps
command = ${bsdep} -g ${bsb_dir_group} -MD ${in}
description = Building ${out}
build IsScoped.mlast.d : build_deps IsScoped.mlast
rule build_cmj_cmi
command = ${bsc} ${bs_package_flags} -bs-assume-no-mli -bs-no-builtin-ppx-ml -bs-no-implicit-include ${bs_package_includes} ${bsc_lib_includes} ${bsc_extra_includes} ${bsc_flags} -o ${in} -c ${in} ${postbuild}
depfile = ${in}.d
description = Building ${out}
build IsScoped.cmj $src_root_dir/lib/js/IsScoped.js IsScoped.cmi : build_cmj_cmi IsScoped.mlast
bs_package_flags = $bs_package_flags -bs-package-output commonjs:lib/js
build build.ninja : phony || IsScoped.mlast.d
15 changes: 15 additions & 0 deletions src/modules/@knit/is-scoped/lib/js/isScoped.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/modules/@knit/is-scoped/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@knit/is-scoped",
"version": "0.4.0"
"version": "0.4.0",
"main": "lib/js/isScoped"
}
2 changes: 1 addition & 1 deletion src/modules/@knit/knit/tasks/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { TModules } from "@knit/knit-core";
const Listr = require("listr");

const needle = require("@knit/needle");
const pathJoin = require("@knit/path-join");
import { pathJoin } from "@knit/path-join";
const execa = require("execa");

type TCtx = {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/@knit/knit/tasks/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import yarn from "@knit/yarn-utils";

const Listr = require("listr");

const pathJoin = require("@knit/path-join");
import { pathJoin } from "@knit/path-join";
const needle = require("@knit/needle");

type TCtx = {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/@knit/knit/tasks/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import readPkg from "@knit/read-pkg";

const Listr = require("listr");

const pathJoin = require("@knit/path-join");
import { pathJoin } from "@knit/path-join";
const needle = require("@knit/needle");
const yarn = require("@knit/yarn-utils");

Expand Down
2 changes: 1 addition & 1 deletion src/modules/@knit/knit/tasks/stitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import writePkg from "write-pkg";
import { findDependencies } from "@knit/find-dependencies";

const knit = require("@knit/knit-core");
const pathJoin = require("@knit/path-join");
import { pathJoin } from "@knit/path-join";
const needle = require("@knit/needle");

type TCtx = {
Expand Down
5 changes: 5 additions & 0 deletions src/modules/@knit/path-join/PathJoin.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
external join : string => string => string = "" [@@bs.module "path"];

external sep : string = "" [@@bs.module "path"];

let pathJoin dir_path package => Js.String.replace "/" sep (join dir_path package);
13 changes: 4 additions & 9 deletions src/modules/@knit/path-join/__tests__/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

const path = require("path");

const pj = require("..");
import { pathJoin as pj } from "../lib/js/main";

describe("pathJoin", () => {
it("still works like path.join", () => {
expect(pj("foo", "bar", "module")).toBe(path.join("foo", "bar", "module"));
});
it("create path when passed scoped module", () => {
expect(pj("foo", "bar", "@scope/package")).toBe(
path.join("foo", "bar", "@scope", "package")
expect(pj("foo", "@scope/package")).toBe(
path.join("foo", "@scope", "package")
);
});
it("keep abs path", () => {
expect(pj("/foo", "bar", "package")).toBe(
path.join("/foo", "bar", "package")
);
expect(pj("/foo", "package")).toBe(path.join("/foo", "package"));
});
});
17 changes: 17 additions & 0 deletions src/modules/@knit/path-join/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@knit/path-join",
"sources": {
"dir": ".",
"public": ["PathJoin"],
"files": [
"PathJoin.re"
]
},
"package-specs": [
"commonjs"
],
"bsc-flags": [
"-bs-cross-module-opt"
],
"generate-merlin": false
}
2 changes: 1 addition & 1 deletion src/modules/@knit/path-join/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ type TPathJoin = (p: string) => string;
const pathJoin: TPathJoin = (...paths) =>
path.join(...paths).replace("/", path.sep);

module.exports = pathJoin;
export { pathJoin };
Binary file added src/modules/@knit/path-join/lib/bs/.bsbuild
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/bs/.bsdeps
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/bs/.ninja_deps
Binary file not shown.
6 changes: 6 additions & 0 deletions src/modules/@knit/path-join/lib/bs/.ninja_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ninja log v5
0 99 0 PathJoin.mlast 22d364da98b3830f
99 111 0 PathJoin.mlast.d 3a5e7da149edcade
0 16 0 PathJoin.cmj cd09c4b001f87e4f
0 16 0 /Users/swilson/Documents/Development/js/knitjs/knit/src/modules/@knit/path-join/lib/js/PathJoin.js cd09c4b001f87e4f
0 16 0 PathJoin.cmi cd09c4b001f87e4f
1 change: 1 addition & 0 deletions src/modules/@knit/path-join/lib/bs/.sourcedirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Binary file added src/modules/@knit/path-join/lib/bs/PathJoin.cmi
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/bs/PathJoin.cmj
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/bs/PathJoin.cmt
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/bs/PathJoin.mlast
Binary file not shown.
1 change: 1 addition & 0 deletions src/modules/@knit/path-join/lib/bs/PathJoin.mlast.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PathJoin.cmj :
30 changes: 30 additions & 0 deletions src/modules/@knit/path-join/lib/bs/build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ninja_required_version = 1.5.1
bs_package_flags = -bs-package-name @knit/path-join
src_root_dir = /Users/swilson/Documents/Development/js/knitjs/knit/src/modules/@knit/path-join
bsc = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/bsc.exe
bsdep = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/bsb_helper.exe
ocamllex = ocamllex.opt
bsc_flags = -nostdlib -I /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/lib/ocaml -bs-cross-module-opt -no-alias-deps -color always -w -40+6+7+27+32..39+44+45
ppx_flags =
bs_package_includes =
bs_package_dev_includes =
refmt = /Users/swilson/Documents/Development/js/knitjs/knit/node_modules/bs-platform/bin/refmt.exe
reason_react_jsx =
refmt_flags = --print binary
bsb_dir_group = 0
bsc_lib_includes = -I .
rule build_ast_and_deps_from_reason_impl
command = ${bsc} -pp "${refmt} ${refmt_flags}" ${reason_react_jsx} ${ppx_flags} ${bsc_flags} -c -o ${out} -bs-syntax-only -bs-binary-ast -impl ${in}
description = Building ${out}
build PathJoin.mlast : build_ast_and_deps_from_reason_impl $src_root_dir/PathJoin.re
rule build_deps
command = ${bsdep} -g ${bsb_dir_group} -MD ${in}
description = Building ${out}
build PathJoin.mlast.d : build_deps PathJoin.mlast
rule build_cmj_cmi
command = ${bsc} ${bs_package_flags} -bs-assume-no-mli -bs-no-builtin-ppx-ml -bs-no-implicit-include ${bs_package_includes} ${bsc_lib_includes} ${bsc_extra_includes} ${bsc_flags} -o ${in} -c ${in} ${postbuild}
depfile = ${in}.d
description = Building ${out}
build PathJoin.cmj $src_root_dir/lib/js/PathJoin.js PathJoin.cmi : build_cmj_cmi PathJoin.mlast
bs_package_flags = $bs_package_flags -bs-package-output commonjs:lib/js
build build.ninja : phony || PathJoin.mlast.d
11 changes: 11 additions & 0 deletions src/modules/@knit/path-join/lib/js/pathJoin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/modules/@knit/path-join/lib/ocaml/.bsbuild
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/ocaml/.bsdeps
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/ocaml/.ninja_deps
Binary file not shown.
6 changes: 6 additions & 0 deletions src/modules/@knit/path-join/lib/ocaml/.ninja_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ninja log v5
0 99 0 PathJoin.mlast 22d364da98b3830f
99 111 0 PathJoin.mlast.d 3a5e7da149edcade
0 16 0 PathJoin.cmj cd09c4b001f87e4f
0 16 0 /Users/swilson/Documents/Development/js/knitjs/knit/src/modules/@knit/path-join/lib/js/PathJoin.js cd09c4b001f87e4f
0 16 0 PathJoin.cmi cd09c4b001f87e4f
1 change: 1 addition & 0 deletions src/modules/@knit/path-join/lib/ocaml/.sourcedirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
Binary file added src/modules/@knit/path-join/lib/ocaml/PathJoin.cmi
Binary file not shown.
Binary file added src/modules/@knit/path-join/lib/ocaml/PathJoin.cmj
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions src/modules/@knit/path-join/lib/ocaml/PathJoin.mlast.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PathJoin.cmj :
Loading

0 comments on commit 7b75861

Please sign in to comment.