Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsb test #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ coverage
.idea
*.iml
.vscode
.merlin

# build folders
build
dist
**/lib/bs
**/lib/ocaml
/lib

# OS
.DS_Store
16 changes: 16 additions & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "this_just_for_the_root_merlin_file_for_text_editor",
"sources": [
{
"dir": "src",
"subdirs": []
}
],
"bs-dev-dependencies": [
"immutable-re",
"@knit/is-scoped",
"@knit/path-join",
"@knit/read-pkg"
],
"generate-merlin": true
}
12 changes: 11 additions & 1 deletion package-lock.json

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

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"file-loader": "^0.10.1",
"fs-extra": "^3.0.1",
"html-webpack-plugin": "^2.28.0",
"immutable-re": "0.0.15",
"json-loader": "^0.5.4",
"listr": "^0.12.0",
"listr-silent-renderer": "^1.1.1",
Expand All @@ -61,10 +62,13 @@
},
"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 -make-world",
"build-ocaml": "yarn knit -- exec --concurrently --include=is-scoped path-join read-pkg -- knit copy --workingDir lib/bs --outputDir lib/ocaml",
"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 +113,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
9 changes: 9 additions & 0 deletions src/modules/@knit/is-scoped/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"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 };
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 "..";

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"));
});
});
9 changes: 9 additions & 0 deletions src/modules/@knit/path-join/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@knit/path-join",
"sources": ".",
"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 };
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.

3 changes: 2 additions & 1 deletion src/modules/@knit/path-join/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@knit/path-join",
"version": "0.4.0"
"version": "0.4.0",
"main": "lib/js/pathJoin"
}
8 changes: 8 additions & 0 deletions src/modules/@knit/read-pkg/ReadPkg.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type syncOptions = {normalize: bool};

external sync : Js.String.t => syncOptions => string = "" [@@bs.module "read-pkg"];

let readPkg dir_path package => {
let ret = sync (PathJoin.pathJoin dir_path package) {normalize: false};
()
};
12 changes: 12 additions & 0 deletions src/modules/@knit/read-pkg/bsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@knit/read-pkg",
"sources": ".",
"package-specs": ["commonjs"],
"bsc-flags": [
"-bs-cross-module-opt"
],
"bs-dependencies": [
"@knit/path-join"
],
"generate-merlin": false
}
2 changes: 1 addition & 1 deletion src/modules/@knit/read-pkg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import rp from "read-pkg";

import pathJoin from "@knit/path-join";
import { pathJoin } from "@knit/path-join";

import type { TPkgJson } from "@knit/needle";

Expand Down
13 changes: 13 additions & 0 deletions src/modules/@knit/read-pkg/lib/js/readPkg.js

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