ソースを参照

Update the package template

Steven Silvester 5 年 前
コミット
01d1890082

+ 5 - 0
buildutils/src/create-package.ts

@@ -37,6 +37,11 @@ void inquirer.prompt(questions).then(answers => {
   data.name = name;
   data.description = description;
   utils.writePackageData(jsonPath, data);
+
+  // Add the launch file to git.
+  const launch = path.join(dest, '.vscode', 'launch.json');
+  utils.run(`git add -f ${launch}`);
+
   // Use npm here so this file can be used outside of JupyterLab.
   utils.run('npm run integrity');
 });

+ 1 - 0
buildutils/template/babel.config.js

@@ -0,0 +1 @@
+module.exports = require('@jupyterlab/testutils/lib/babel.config');

+ 2 - 0
buildutils/template/jest.config.js

@@ -0,0 +1,2 @@
+const func = require('@jupyterlab/testutils/lib/jest-config');
+module.exports = func(__dirname);

+ 15 - 0
buildutils/template/launch.json

@@ -0,0 +1,15 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "type": "node",
+      "request": "attach",
+      "name": "Attach to jest",
+      // Usage:
+      // Open the parent directory in VSCode
+      // Run \`jlpm test:debug:watch\` in a terminal
+      // Run this debugging task
+      "port": 9229
+    }
+  ]
+}

+ 12 - 3
buildutils/template/package.json

@@ -26,13 +26,22 @@
     "lib": "lib/"
   },
   "scripts": {
-    "build": "tsc",
-    "clean": "rimraf lib",
+    "build": "tsc -b",
+    "build:test": "tsc --build tsconfig.test.json",
+    "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
     "prepublishOnly": "npm run build",
-    "watch": "tsc -w --listEmittedFiles"
+    "test": "jest",
+    "test:cov": "jest --collect-coverage",
+    "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
+    "test:debug:watch": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
+    "watch": "tsc -b --watch"
   },
   "devDependencies": {
+    "@jupyterlab/testutils": "^2.1.0",
+    "@types/jest": "^24.0.23",
+    "jest": "^25.2.3",
     "rimraf": "~3.0.0",
+    "ts-jest": "^25.2.1",
     "typescript": "~3.7.3"
   },
   "publishConfig": {

+ 4 - 0
buildutils/template/tsconfig.test.json

@@ -0,0 +1,4 @@
+{
+  "extends": "../../tsconfigbase.test",
+  "include": ["src/*", "test/*"]
+}

+ 0 - 1
buildutils/test-template/karma-cov.conf.js

@@ -1 +0,0 @@
-module.exports = require('../karma-cov.conf');

+ 0 - 1
buildutils/test-template/karma.conf.js

@@ -1 +0,0 @@
-module.exports = require('../karma.conf');

+ 0 - 22
buildutils/test-template/package.json

@@ -1,22 +0,0 @@
-{
-  "name": "template-for-tests",
-  "version": "2.1.0",
-  "private": true,
-  "scripts": {
-    "build": "tsc",
-    "clean": "rimraf build && rimraf coverage",
-    "coverage": "python run-test.py --browsers ChromeHeadless karma-cov.conf.js",
-    "test": "jlpm run test:firefox",
-    "test:chrome": "python run-test.py --browsers=Chrome karma.conf.js",
-    "test:debug": "python run-test.py  --browsers=Chrome --singleRun=false --debug=true --browserNoActivityTimeout=10000000 karma.conf.js",
-    "test:firefox": "python run-test.py --browsers=Firefox karma.conf.js",
-    "test:ie": "python run-test.py  --browsers=IE karma.conf.js",
-    "watch": "python run-test.py --singleRun=false",
-    "watch:src": "tsc -w --listEmittedFiles"
-  },
-  "devDependencies": {
-    "karma": "^4.4.1",
-    "rimraf": "~3.0.0",
-    "typescript": "~3.7.3"
-  }
-}

+ 0 - 10
buildutils/test-template/run-test.py

@@ -1,10 +0,0 @@
-# Copyright (c) Jupyter Development Team.
-# Distributed under the terms of the Modified BSD License.
-
-import os
-from jupyterlab.tests.test_app import run_karma
-
-HERE = os.path.realpath(os.path.dirname(__file__))
-
-if __name__ == '__main__':
-    run_karma(HERE)

+ 0 - 2
buildutils/test-template/src/mypackage.spec.ts

@@ -1,2 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.

+ 0 - 8
buildutils/test-template/tsconfig.json

@@ -1,8 +0,0 @@
-{
-  "extends": "../../tsconfigbase",
-  "compilerOptions": {
-    "outDir": "build",
-    "rootDir": "src"
-  },
-  "include": ["src/*"]
-}