diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index afc1288e3..490321be7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -6,8 +6,40 @@ on: # - master jobs: + Build: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + atom_channel: + - stable + steps: + - uses: actions/checkout@v2 + - uses: atom-community/action-setup-atom@v1 + with: + channel: ${{ matrix.atom_channel }} + + - name: Install dependencies and build + run: | + apm install + + npm run clean + npm run tsc || echo done + + npm run build + + - name: Upload built files + uses: actions/upload-artifact@v2 + with: + path: | + ./dist + Test: if: "!contains(github.event.head_commit.message, '[skip ci]')" + needs: Build name: ${{ matrix.os }} - Atom ${{ matrix.atom_channel }} runs-on: ${{ matrix.os }} strategy: @@ -24,10 +56,19 @@ jobs: with: channel: ${{ matrix.atom_channel }} - - name: Install dependencies and build + - name: Download articats + uses: actions/download-artifact@v2 + - name: Place artifacts + shell: bash + run: | + rm -rf ./dist + mkdir ./dist + cp -r ./artifact/* ./dist + rm -rf ./artifact + + - name: Install dependencies run: | apm install - npm run build - name: Run tests 👩🏾‍💻 run: npm run test @@ -54,10 +95,3 @@ jobs: - name: Lint ✨ run: npm run test.lint - - Skip: - if: contains(github.event.head_commit.message, '[skip ci]') - runs-on: ubuntu-latest - steps: - - name: Skip CI 🚫 - run: echo skip ci diff --git a/.npmrc b/.npmrc index ac5613f69..9eccfb6c8 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,3 @@ public-hoist-pattern[]=* -package-lock=false lockfile=true prefer-frozen-lockfile=false diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 000000000..469e76ee6 --- /dev/null +++ b/babel.config.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["@babel/plugin-proposal-decorators", { "legacy": true }], + ["@babel/plugin-proposal-class-properties", { "loose": true }] + ] +} diff --git a/lib/ws-kernel-picker.ts b/lib/ws-kernel-picker.ts index a8ae1f3cd..230fa347f 100644 --- a/lib/ws-kernel-picker.ts +++ b/lib/ws-kernel-picker.ts @@ -5,7 +5,6 @@ import isEmpty from "lodash/isEmpty"; import tildify from "tildify"; import { v4 } from "uuid"; import ws from "ws"; -import { XMLHttpRequest as NodeXMLHttpRequest } from "xmlhttprequest"; // TODO use @aminya/xmlhttprequest import { URL } from "url"; import { Kernel, Session, ServerConnection } from "@jupyterlab/services"; import Config from "./config"; @@ -198,7 +197,9 @@ export default class WSKernelPicker { options.requestHeaders.Cookie = cookie; options.xhrFactory = () => { - const request = new NodeXMLHttpRequest(); + // we use xmlhttprequest because it allows disabling header protection + const { XMLHttpRequest } = require("xmlhttprequest"); // TODO use @aminya/xmlhttprequest + const request = new XMLHttpRequest(); // Disable protections against setting the Cookie header request.setDisableHeaderCheck(true); return request as XMLHttpRequest; // TODO fix the types diff --git a/package.json b/package.json index d74c024f8..8a4a2f1bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Hydrogen", - "main": "./dist/main", + "main": "./dist/main.js", "version": "2.16.3", "description": "Run code interactively, inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor.", "author": "nteract contributors", @@ -43,14 +43,13 @@ "test": "echo 'test without rebuilding' && atom --test spec", "clean": "shx rm -rf dist", "clean.prod": "shx rm -rf ./dist/**/*.d.ts ./dist/tsconfig.tsbuildinfo", - "dev": "npm run clean && tsc -p lib/tsconfig.json --watch", "tsc": "tsc -p lib/tsconfig.json || echo done", - "build": "npm run clean && npm run tsc && npm run clean.prod", + "dev": "npm run tsc -- --watch", + "build": "cross-env NODE_ENV=production parcel build ./lib/main.ts --detailed-report", "build:services-docs": "markdox lib/services/index.js -o lib/services/README.md", "build:plugin-docs": "markdox lib/plugin-api/hydrogen-provider.js lib/plugin-api/hydrogen-kernel.js -o docs/PluginAPI.md", "build:docs": "npm run build:plugin-docs && npm run build:services-docs", - "build-commit": "build-commit -o dist", - "prepare": "npm run build" + "build-commit": "npm run clean && build-commit -o dist" }, "atomTestRunner": "atom-jasmine3-test-runner", "repository": "https://github.com/nteract/hydrogen", @@ -113,6 +112,8 @@ } }, "devDependencies": { + "@babel/plugin-proposal-class-properties": "^7.13.0", + "@babel/plugin-proposal-decorators": "^7.14.2", "@nteract/types": "^7.1.7", "@types/atom": "^1.40.10", "@types/enzyme": "^3.10.8", @@ -128,15 +129,52 @@ "@types/ws": "^7.4.1", "atom-jasmine3-test-runner": "^5.2.5", "build-commit": "^0.1.4", + "cross-env": "^7.0.3", "electron": "^6", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.6", "eslint-config-atomic": "^1.14.4", "eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0", "markdox": "^0.1.10", + "parcel": "^2.0.0-beta.3.1", "prettier-config-atomic": "^2.0.5", "react-test-renderer": "^17.0.2", "shx": "^0.3.3", "typescript": "^4.2.4" + }, + "targets": { + "main": { + "context": "electron-renderer", + "engines": { + "electron": ">=6.x" + }, + "includeNodeModules": { + "atom": false, + "electron": false, + "@aminya/zeromq": false, + "canvas": false, + "react": false, + "react-dom": false, + "react-refresh": false, + "mobx-react": false, + "@nteract/plotly": false, + "refractor": false, + "highlight.js": false, + "mathjax-electron": false, + "xmlhttprequest": false + }, + "isLibrary": true + } + }, + "alias": { + "async": "async/index.js", + "moment": "moment/src/moment.js", + "mobx": "mobx/lib/mobx.module.js", + "immutable": "immutable/dist/immutable.es.js", + "@emotion/stylis": "@emotion/stylis/dist/stylis.esm.js", + "re-resizable": "re-resizable/lib/index.js", + "react-syntax-highlighter": "react-syntax-highlighter/dist/esm/index.js", + "react-syntax-highlighter/dist/cjs/styles/prism/vs": "react-syntax-highlighter/dist/esm/styles/prism/vs.js", + "react-syntax-highlighter/dist/cjs/styles/prism/xonokai": "react-syntax-highlighter/dist/esm/styles/prism/xonokai.js" } }