From 0984c4516194705704c7a0b4f927b6260f78d4c7 Mon Sep 17 00:00:00 2001 From: Maciej Lenartowicz Date: Fri, 1 Nov 2019 09:28:28 +0000 Subject: [PATCH] Flat structure of published package --- .gitlab-ci.yml | 13 +++++++------ Makefile | 11 ++++++++++- babel.config.js | 4 ++-- package.json | 9 ++------- scripts/collect_files.sh | 9 +++++++++ scripts/publish.sh | 4 ++-- src/index.js | 4 ---- src/testUtils/customTestRender.js | 2 +- 8 files changed, 33 insertions(+), 23 deletions(-) create mode 100644 scripts/collect_files.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dac26a3..76aa24e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,25 +6,26 @@ stages: - publish before_script: + - apk add make - npm install test: stage: test script: - - npm test + - make test lint: stage: test script: - - npm run lint + - make lint build: stage: build script: - - npm pack + - make pack artifacts: paths: - - foris-*.tgz + - dist/foris-*.tgz publish_beta: stage: publish @@ -32,7 +33,7 @@ publish_beta: refs: - dev script: - - sh scripts/publish.sh beta + - make publish-beta publish_latest: stage: publish @@ -40,4 +41,4 @@ publish_latest: refs: - master script: - - sh scripts/publish.sh latest + - make publish-latest diff --git a/Makefile b/Makefile index 2ddbdea..1d58e95 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all install-js watch-js build-js lint-js test-js create-messages update-messages docs clean +.PHONY: all install-js watch-js build-js collect-files pack publish-beta publish-latest lint test test-js-update-snapshots create-messages update-messages docs docs-watch clean all: @echo "make install-js" @@ -30,6 +30,15 @@ watch-js: build-js: npm run build +collect-files: + sh scripts/collect_files.sh +pack: collect-files + cd dist && npm pack +publish-beta: collect-files + sh scripts/publish.sh beta +publish-latest: collect-files + sh scripts/publish.sh latest + lint: npm run lint diff --git a/babel.config.js b/babel.config.js index cb37526..5d9e8a8 100644 --- a/babel.config.js +++ b/babel.config.js @@ -16,10 +16,10 @@ module.exports = { ], env: { development: { - ignore: ["**/__tests__", "./scripts"], + ignore: ["**/__tests__/**", "**/__mocks__/**"], }, test: { - ignore: ["./scripts"], + ignore: [], }, }, }; diff --git a/package.json b/package.json index c2e8123..ce38bc6 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "reforis" ], "license": "GPL-3.0", - "main": "./dist/index.js", + "main": "index.js", "dependencies": { "axios": "^0.19.0", "immutability-helper": "^3.0.0", @@ -68,16 +68,11 @@ "scripts": { "build": "rm -rf dist; babel src --out-dir dist --source-maps inline --copy-files", "build:watch": "babel src --verbose --watch --out-dir dist --source-maps inline --copy-files", - "prepare": "rm -rf ./dist && npm run build", "lint": "eslint src", "test": "jest", "test:watch": "jest --watch", "test:coverage": "jest --coverage --colors", "docs": "npx styleguidist build ", "docs:watch": "styleguidist server" - }, - "files": [ - "dist/**", - "translations" - ] + } } diff --git a/scripts/collect_files.sh b/scripts/collect_files.sh new file mode 100644 index 0000000..6d45f1b --- /dev/null +++ b/scripts/collect_files.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Collect files +npm run build +cp package.json dist +cp -rf translations dist +# Remove unwanted files +rm -rf dist/**/__tests__ +rm -rf dist/__mocks__ diff --git a/scripts/publish.sh b/scripts/publish.sh index e18e977..ce3dc5e 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -12,10 +12,10 @@ else then BETA_VERSION=$(npx -c 'echo "$npm_package_version"')-beta.$CI_COMMIT_SHORT_SHA npm version "$BETA_VERSION" --git-tag-version false - npm publish --tag beta + cd dist && npm publish --tag beta elif test "$1" = "latest" then - npm publish + cd dist && npm publish else echo "Usage: publish.sh [ beta | latest ]" exit 1 diff --git a/src/index.js b/src/index.js index c412869..851d2ba 100644 --- a/src/index.js +++ b/src/index.js @@ -67,7 +67,3 @@ export { // Alert context export { AlertContext, AlertContextProvider, useAlert } from "alertContext/AlertContext"; - -// Testing utilities -export { mockJSONError } from "testUtils/network"; -export { mockSetAlert, mockDismissAlert } from "testUtils/alertContextMock"; diff --git a/src/testUtils/customTestRender.js b/src/testUtils/customTestRender.js index 9092f72..fbf1718 100644 --- a/src/testUtils/customTestRender.js +++ b/src/testUtils/customTestRender.js @@ -13,7 +13,7 @@ import { StaticRouter } from "react-router"; import { render } from "@testing-library/react"; import PropTypes from "prop-types"; -import { AlertContextMock } from "alertContextMock"; +import { AlertContextMock } from "./alertContextMock"; Wrapper.propTypes = { children: PropTypes.oneOfType([