From 09a295397d4010b7fd43938d2408d64674a22df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cha=CC=81varri?= Date: Mon, 23 Oct 2017 23:46:11 +0200 Subject: [PATCH 1/5] Add bs-stdlib package --- .npmignore | 1 + jscomp/core/js_packages_info.ml | 4 +++- lib/package.json | 29 +++++++++++++++++++++++++++++ package.json | 3 ++- scripts/prepublish.sh | 11 +++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 lib/package.json create mode 100755 scripts/prepublish.sh diff --git a/.npmignore b/.npmignore index 581e6b4ccf..21c4a5041a 100644 --- a/.npmignore +++ b/.npmignore @@ -12,6 +12,7 @@ docs/* docs/docson/* !docs/docson/build-schema.json site/ +lib/ .vscode/ .github/ odoc_gen diff --git a/jscomp/core/js_packages_info.ml b/jscomp/core/js_packages_info.ml index 6416529ddb..c8cd1115d7 100644 --- a/jscomp/core/js_packages_info.ml +++ b/jscomp/core/js_packages_info.ml @@ -238,7 +238,9 @@ let string_of_module_id else begin match module_system with | AmdJS | NodeJS | Es6 -> - dep_package_name // dep_path // js_file + (* HACK - TODO Replace bs-stdlib upstream and not here *) + let upd_dep_package_name = if dep_package_name = "bs-platform" then "bs-stdlib" else dep_package_name in + upd_dep_package_name // dep_path // js_file (** Note we did a post-processing when working on Windows *) | Es6_global | AmdJS_global -> diff --git a/lib/package.json b/lib/package.json new file mode 100644 index 0000000000..fbaaad5318 --- /dev/null +++ b/lib/package.json @@ -0,0 +1,29 @@ +{ + "name": "bs-stdlib", + "version": "1.9.4", + "description": "BuckleScript compiled JS standard library", + "repository": { + "type": "git", + "url": "git+https://github.com/bucklescript/bucklescript.git" + }, + "keywords": [ + "ocaml", + "bucklescript", + "stdlib", + "functional programming" + ], + "author": { + "name": "Hongbo Zhang" + }, + "maintainers": [ + { + "name": "hongbo_zhang", + "email": "bobzhang1988@gmail.com" + } + ], + "license": "SEE LICENSE IN LICENSE", + "bugs": { + "url": "https://github.com/bucklescript/bucklescript/issues" + }, + "homepage": "https://github.com/bucklescript/bucklescript#readme" +} diff --git a/package.json b/package.json index 85a385a06b..35f136ea4b 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "cover": "istanbul cover --report html ./node_modules/.bin/_mocha -- ./jscomp/test/**/*test.js && open coverage/index.html", "coverage": "istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- './jscomp/test/*test.js'", "coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info", - "postinstall": "node scripts/install.js" + "postinstall": "node scripts/install.js", + "prepublishOnly": "./scripts/prepublish.sh" }, "name": "bs-platform", "version": "2.2.3", diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh new file mode 100755 index 0000000000..6c75c07f91 --- /dev/null +++ b/scripts/prepublish.sh @@ -0,0 +1,11 @@ +#!/bin/sh +MAIN_PACKAGE_VERSION=$(node -p -e "require('./package.json').version") +STDLIB_PACKAGE_VERSION=$(node -p -e "require('./lib/package.json').version") + +echo "**Preparing and publishing bs-stdlib...**\n" + +if [ $MAIN_PACKAGE_VERSION == $STDLIB_PACKAGE_VERSION ]; then + cd jscomp && make world && cd ../lib && echo $PACKAGE_VERSION && npm publish +else + echo "Error: bs-platform and bs-stdlib don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and bs-stdlib is $STDLIB_PACKAGE_VERSION" +fi From f8d5169b1b663d0308d6a601521273813e1ee9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cha=CC=81varri?= Date: Sun, 18 Mar 2018 23:20:41 +0100 Subject: [PATCH 2/5] Create new folder belt-js --- belt-js/.gitignore | 1 + belt-js/LICENSE | 23 +++++++++++++++++++++++ {lib => belt-js}/package.json | 6 +++--- jscomp/core/js_packages_info.ml | 4 ++-- scripts/prepublish.sh | 17 ++++++++++++----- 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 belt-js/.gitignore create mode 100644 belt-js/LICENSE rename {lib => belt-js}/package.json (83%) diff --git a/belt-js/.gitignore b/belt-js/.gitignore new file mode 100644 index 0000000000..c3af857904 --- /dev/null +++ b/belt-js/.gitignore @@ -0,0 +1 @@ +lib/ diff --git a/belt-js/LICENSE b/belt-js/LICENSE new file mode 100644 index 0000000000..04505f9feb --- /dev/null +++ b/belt-js/LICENSE @@ -0,0 +1,23 @@ +Copyright (C) 2015-2016 Bloomberg Finance L.P. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +In addition to the permissions granted to you by the LGPL, you may combine +or link a "work that uses the Library" with a publicly distributed version +of this file to produce a combined library or application, then distribute +that combined work under the terms of your choosing, with no requirement +to comply with the obligations normally placed on you by section 4 of the +LGPL version 3 (or the corresponding section of a later version of the LGPL +should you choose to use a later version). + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. \ No newline at end of file diff --git a/lib/package.json b/belt-js/package.json similarity index 83% rename from lib/package.json rename to belt-js/package.json index fbaaad5318..4dc4f50001 100644 --- a/lib/package.json +++ b/belt-js/package.json @@ -1,7 +1,7 @@ { - "name": "bs-stdlib", - "version": "1.9.4", - "description": "BuckleScript compiled JS standard library", + "name": "belt-js", + "version": "2.2.3", + "description": "BuckleScript compiled standard libraries", "repository": { "type": "git", "url": "git+https://github.com/bucklescript/bucklescript.git" diff --git a/jscomp/core/js_packages_info.ml b/jscomp/core/js_packages_info.ml index c8cd1115d7..206f2dc41e 100644 --- a/jscomp/core/js_packages_info.ml +++ b/jscomp/core/js_packages_info.ml @@ -238,8 +238,8 @@ let string_of_module_id else begin match module_system with | AmdJS | NodeJS | Es6 -> - (* HACK - TODO Replace bs-stdlib upstream and not here *) - let upd_dep_package_name = if dep_package_name = "bs-platform" then "bs-stdlib" else dep_package_name in + (* HACK - TODO Replace belt-js upstream and not here *) + let upd_dep_package_name = if dep_package_name = "bs-platform" then "belt-js" else dep_package_name in upd_dep_package_name // dep_path // js_file (** Note we did a post-processing when working on Windows *) | Es6_global diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh index 6c75c07f91..3150598b1f 100755 --- a/scripts/prepublish.sh +++ b/scripts/prepublish.sh @@ -1,11 +1,18 @@ #!/bin/sh +BELT_FOLDER_NAME="belt-js" MAIN_PACKAGE_VERSION=$(node -p -e "require('./package.json').version") -STDLIB_PACKAGE_VERSION=$(node -p -e "require('./lib/package.json').version") +BELT_PACKAGE_VERSION=$(node -p -e "require('./$BELT_FOLDER_NAME/package.json').version") -echo "**Preparing and publishing bs-stdlib...**\n" +echo "**Preparing and publishing belt-js...**\n" -if [ $MAIN_PACKAGE_VERSION == $STDLIB_PACKAGE_VERSION ]; then - cd jscomp && make world && cd ../lib && echo $PACKAGE_VERSION && npm publish +if [ $MAIN_PACKAGE_VERSION == $BELT_PACKAGE_VERSION ]; then + # make && make install && \ + cd jscomp && cd ../belt-js && \ + mkdir -p ./lib/js && cp ../lib/js/* ./lib/js && \ + mkdir -p ./lib/amdjs && cp ../lib/amdjs/* ./lib/amdjs && \ + mkdir -p ./lib/es6 && cp ../lib/es6/* ./lib/es6 && \ + echo "Finished prepublishing $BELT_FOLDER_NAME, version $BELT_PACKAGE_VERSION" + # && npm publish else - echo "Error: bs-platform and bs-stdlib don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and bs-stdlib is $STDLIB_PACKAGE_VERSION" + echo "Error: bs-platform and belt-js don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and belt-js is $BELT_PACKAGE_VERSION" fi From f8abc79c59067ba782e362c8d7b7986b6254de8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cha=CC=81varri?= Date: Sun, 18 Mar 2018 23:32:20 +0100 Subject: [PATCH 3/5] Add belt-js to every template --- .npmignore | 4 +++- jscomp/bsb/templates/basic-reason/package.json | 3 +++ jscomp/bsb/templates/basic/package.json | 3 +++ jscomp/bsb/templates/generator/package.json | 3 +++ jscomp/bsb/templates/minimal/package.json | 3 +++ jscomp/bsb/templates/node/package.json | 3 +++ jscomp/bsb/templates/react/package.json | 1 + 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 21c4a5041a..81cf27234d 100644 --- a/.npmignore +++ b/.npmignore @@ -12,7 +12,9 @@ docs/* docs/docson/* !docs/docson/build-schema.json site/ -lib/ +lib/amdjs +lib/es6 +lib/js .vscode/ .github/ odoc_gen diff --git a/jscomp/bsb/templates/basic-reason/package.json b/jscomp/bsb/templates/basic-reason/package.json index cd6226a967..618fbd27d3 100644 --- a/jscomp/bsb/templates/basic-reason/package.json +++ b/jscomp/bsb/templates/basic-reason/package.json @@ -11,6 +11,9 @@ ], "author": "", "license": "MIT", + "dependencies": { + "belt-js": "${bsb:bs-version}" + }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/basic/package.json b/jscomp/bsb/templates/basic/package.json index 08287d8360..2494f95759 100644 --- a/jscomp/bsb/templates/basic/package.json +++ b/jscomp/bsb/templates/basic/package.json @@ -11,6 +11,9 @@ ], "author": "", "license": "MIT", + "dependencies": { + "belt-js": "${bsb:bs-version}" + }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/generator/package.json b/jscomp/bsb/templates/generator/package.json index 08287d8360..2494f95759 100644 --- a/jscomp/bsb/templates/generator/package.json +++ b/jscomp/bsb/templates/generator/package.json @@ -11,6 +11,9 @@ ], "author": "", "license": "MIT", + "dependencies": { + "belt-js": "${bsb:bs-version}" + }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/minimal/package.json b/jscomp/bsb/templates/minimal/package.json index 5ae9b7e297..ce4947bab3 100644 --- a/jscomp/bsb/templates/minimal/package.json +++ b/jscomp/bsb/templates/minimal/package.json @@ -11,6 +11,9 @@ ], "author": "", "license": "MIT", + "dependencies": { + "belt-js": "${bsb:bs-version}" + }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/node/package.json b/jscomp/bsb/templates/node/package.json index 08287d8360..2494f95759 100644 --- a/jscomp/bsb/templates/node/package.json +++ b/jscomp/bsb/templates/node/package.json @@ -11,6 +11,9 @@ ], "author": "", "license": "MIT", + "dependencies": { + "belt-js": "${bsb:bs-version}" + }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/react/package.json b/jscomp/bsb/templates/react/package.json index 1298d76194..2e0d58e89b 100644 --- a/jscomp/bsb/templates/react/package.json +++ b/jscomp/bsb/templates/react/package.json @@ -15,6 +15,7 @@ "author": "", "license": "MIT", "dependencies": { + "belt-js": "${bsb:bs-version}", "react": "^16.2.0", "react-dom": "^16.2.0", "reason-react": ">=0.3.4" From 899114f2939aa304d4f1dbc5a441fc1a8d8ad9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cha=CC=81varri?= Date: Sun, 18 Mar 2018 23:35:55 +0100 Subject: [PATCH 4/5] Finish prepublish.sh --- scripts/prepublish.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh index 3150598b1f..5ea5d03510 100755 --- a/scripts/prepublish.sh +++ b/scripts/prepublish.sh @@ -6,13 +6,13 @@ BELT_PACKAGE_VERSION=$(node -p -e "require('./$BELT_FOLDER_NAME/package.json').v echo "**Preparing and publishing belt-js...**\n" if [ $MAIN_PACKAGE_VERSION == $BELT_PACKAGE_VERSION ]; then - # make && make install && \ + make && make install && \ cd jscomp && cd ../belt-js && \ mkdir -p ./lib/js && cp ../lib/js/* ./lib/js && \ mkdir -p ./lib/amdjs && cp ../lib/amdjs/* ./lib/amdjs && \ mkdir -p ./lib/es6 && cp ../lib/es6/* ./lib/es6 && \ echo "Finished prepublishing $BELT_FOLDER_NAME, version $BELT_PACKAGE_VERSION" - # && npm publish + && npm publish else echo "Error: bs-platform and belt-js don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and belt-js is $BELT_PACKAGE_VERSION" fi From bd0e6b81148439688cff1b0825b4300cb2c861aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Cha=CC=81varri?= Date: Mon, 19 Mar 2018 02:07:35 +0100 Subject: [PATCH 5/5] Add belt-js as dependency of bs-platform. Remove deps from templates --- jscomp/bsb/templates/basic-reason/package.json | 3 --- jscomp/bsb/templates/basic/package.json | 3 --- jscomp/bsb/templates/generator/package.json | 3 --- jscomp/bsb/templates/minimal/package.json | 3 --- jscomp/bsb/templates/node/package.json | 3 --- jscomp/bsb/templates/react/package.json | 1 - package.json | 3 +++ scripts/prepublish.sh | 13 ++++++++----- 8 files changed, 11 insertions(+), 21 deletions(-) diff --git a/jscomp/bsb/templates/basic-reason/package.json b/jscomp/bsb/templates/basic-reason/package.json index 618fbd27d3..cd6226a967 100644 --- a/jscomp/bsb/templates/basic-reason/package.json +++ b/jscomp/bsb/templates/basic-reason/package.json @@ -11,9 +11,6 @@ ], "author": "", "license": "MIT", - "dependencies": { - "belt-js": "${bsb:bs-version}" - }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/basic/package.json b/jscomp/bsb/templates/basic/package.json index 2494f95759..08287d8360 100644 --- a/jscomp/bsb/templates/basic/package.json +++ b/jscomp/bsb/templates/basic/package.json @@ -11,9 +11,6 @@ ], "author": "", "license": "MIT", - "dependencies": { - "belt-js": "${bsb:bs-version}" - }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/generator/package.json b/jscomp/bsb/templates/generator/package.json index 2494f95759..08287d8360 100644 --- a/jscomp/bsb/templates/generator/package.json +++ b/jscomp/bsb/templates/generator/package.json @@ -11,9 +11,6 @@ ], "author": "", "license": "MIT", - "dependencies": { - "belt-js": "${bsb:bs-version}" - }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/minimal/package.json b/jscomp/bsb/templates/minimal/package.json index ce4947bab3..5ae9b7e297 100644 --- a/jscomp/bsb/templates/minimal/package.json +++ b/jscomp/bsb/templates/minimal/package.json @@ -11,9 +11,6 @@ ], "author": "", "license": "MIT", - "dependencies": { - "belt-js": "${bsb:bs-version}" - }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/node/package.json b/jscomp/bsb/templates/node/package.json index 2494f95759..08287d8360 100644 --- a/jscomp/bsb/templates/node/package.json +++ b/jscomp/bsb/templates/node/package.json @@ -11,9 +11,6 @@ ], "author": "", "license": "MIT", - "dependencies": { - "belt-js": "${bsb:bs-version}" - }, "devDependencies": { "bs-platform": "^${bsb:bs-version}" } diff --git a/jscomp/bsb/templates/react/package.json b/jscomp/bsb/templates/react/package.json index 2e0d58e89b..1298d76194 100644 --- a/jscomp/bsb/templates/react/package.json +++ b/jscomp/bsb/templates/react/package.json @@ -15,7 +15,6 @@ "author": "", "license": "MIT", "dependencies": { - "belt-js": "${bsb:bs-version}", "react": "^16.2.0", "react-dom": "^16.2.0", "reason-react": ">=0.3.4" diff --git a/package.json b/package.json index 35f136ea4b..64ead0caa8 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,7 @@ { + "dependencies": { + "belt-js": "2.2.3" + }, "devDependencies": { "benchmark": "^2.1.4", "colors": "^1.1.2", diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh index 5ea5d03510..bf035b2617 100755 --- a/scripts/prepublish.sh +++ b/scripts/prepublish.sh @@ -1,18 +1,21 @@ #!/bin/sh BELT_FOLDER_NAME="belt-js" MAIN_PACKAGE_VERSION=$(node -p -e "require('./package.json').version") +BELT_IMPORTED_PACKAGE_VERSION=$(node -p -e "require('./package.json').dependencies['belt-js']") BELT_PACKAGE_VERSION=$(node -p -e "require('./$BELT_FOLDER_NAME/package.json').version") echo "**Preparing and publishing belt-js...**\n" -if [ $MAIN_PACKAGE_VERSION == $BELT_PACKAGE_VERSION ]; then +if [ $MAIN_PACKAGE_VERSION != $BELT_PACKAGE_VERSION ]; then + echo "Error: bs-platform and belt-js don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and belt-js is $BELT_PACKAGE_VERSION" +elif [ $BELT_IMPORTED_PACKAGE_VERSION != $BELT_PACKAGE_VERSION ]; then + echo "Error: the imported version of belt-js in bs-platform is not the latest.\nbs-platform is dependent on $BELT_IMPORTED_PACKAGE_VERSION and belt-js version is $BELT_PACKAGE_VERSION" +else make && make install && \ cd jscomp && cd ../belt-js && \ mkdir -p ./lib/js && cp ../lib/js/* ./lib/js && \ mkdir -p ./lib/amdjs && cp ../lib/amdjs/* ./lib/amdjs && \ mkdir -p ./lib/es6 && cp ../lib/es6/* ./lib/es6 && \ - echo "Finished prepublishing $BELT_FOLDER_NAME, version $BELT_PACKAGE_VERSION" - && npm publish -else - echo "Error: bs-platform and belt-js don't have the same version.\nbs-platform is $MAIN_PACKAGE_VERSION and belt-js is $BELT_PACKAGE_VERSION" + echo "Finished prepublishing $BELT_FOLDER_NAME, version $BELT_PACKAGE_VERSION" && \ + npm publish fi