diff --git a/examples/README.md b/examples/README.md index 6310f5e..9c6d87a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,7 +10,7 @@ $ git clone https://github.com/alexandercerutti/passkit-generator.git; $ cd passkit-generator && npm install; $ cd examples && npm install; $ npm run build; -$ node .js +$ npm run example .js ``` Certificates paths in examples are linked to a folder `certificates` in the root of this project which is not provided. diff --git a/examples/abstractModel.ts b/examples/abstractModel.ts index cdf2dbb..0ce9ee2 100644 --- a/examples/abstractModel.ts +++ b/examples/abstractModel.ts @@ -1,5 +1,5 @@ import genRoute, { app } from "./webserver"; -import { createPass, createAbstractModel, AbstractModel } from ".."; +import { createPass, createAbstractModel, AbstractModel } from "passkit-generator"; let abstractModel: AbstractModel; diff --git a/examples/additionalBuffers.ts b/examples/additionalBuffers.ts index 1f220f3..8d6c750 100644 --- a/examples/additionalBuffers.ts +++ b/examples/additionalBuffers.ts @@ -8,14 +8,14 @@ import app from "./webserver"; import fetch from "node-fetch"; -import { createPass } from ".."; +import { createPass } from "passkit-generator"; app.all(async function manageRequest(request, response) { let passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); const avatar = await ( fetch("https://s.gravatar.com/avatar/83cd11399b7ea79977bc302f3931ee52?size=32&default=retro") - .then(res => res.buffer()) + .then(res => res.buffer()) ); const passConfig = { diff --git a/examples/barcode.ts b/examples/barcode.ts index 211c7cf..1d3f59f 100644 --- a/examples/barcode.ts +++ b/examples/barcode.ts @@ -9,7 +9,7 @@ */ import app from "./webserver"; -import { createPass } from ".."; +import { createPass } from "passkit-generator"; app.all(async function manageRequest(request, response) { const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); @@ -45,6 +45,7 @@ app.all(async function manageRequest(request, response) { format: "PKBarcodeFormatPDF417" }, { message: "Thank you for using this package <3", + // @ts-expect-error format: "PKBarcodeFormatMock44617" }); } @@ -65,7 +66,7 @@ app.all(async function manageRequest(request, response) { }); stream.pipe(response); - } catch(err) { + } catch (err) { console.log(err); response.set({ diff --git a/examples/expiration.ts b/examples/expiration.ts index 87a107d..ca650a7 100644 --- a/examples/expiration.ts +++ b/examples/expiration.ts @@ -9,7 +9,7 @@ */ import app from "./webserver"; -import { createPass } from ".."; +import { createPass } from "passkit-generator"; app.all(async function manageRequest(request, response) { if (!request.query.fn) { @@ -51,7 +51,7 @@ app.all(async function manageRequest(request, response) { }); stream.pipe(response); - } catch(err) { + } catch (err) { console.log(err); response.set({ diff --git a/examples/fields.ts b/examples/fields.ts index 91c3ff9..241b552 100644 --- a/examples/fields.ts +++ b/examples/fields.ts @@ -10,7 +10,7 @@ */ import app from "./webserver"; -import { createPass } from ".."; +import { createPass } from "passkit-generator"; app.all(async function manageRequest(request, response) { let passName = "exampleBooking" + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); diff --git a/examples/localization.ts b/examples/localization.ts index 0226fed..55cf44e 100644 --- a/examples/localization.ts +++ b/examples/localization.ts @@ -5,7 +5,7 @@ */ import app from "./webserver"; -import { createPass } from ".."; +import { createPass } from "passkit-generator"; app.all(async function manageRequest(request, response) { const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); diff --git a/examples/package.json b/examples/package.json index 0ff4cd2..4ea9111 100644 --- a/examples/package.json +++ b/examples/package.json @@ -5,7 +5,11 @@ "author": "Alexander P. Cerutti ", "license": "ISC", "scripts": { - "build": "cd ..; npm run build; cd examples" + "preinstall": "npm run clear:deps && npm unlink --no-save passkit-generator && cd .. && npm run build && npm link && cd examples && npm link passkit-generator", + "example": "cd build && node", + "build": "npm run build:clear && npx tsc", + "build:clear": "rm -rf build", + "clear:deps": "rm -rf node_modules" }, "dependencies": { "express": "^4.17.1", diff --git a/examples/tsconfig.json b/examples/tsconfig.json new file mode 100644 index 0000000..c6c7a01 --- /dev/null +++ b/examples/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "build" + }, + "exclude": [ + "node_modules" + ] +} diff --git a/package.json b/package.json index 1bd77c6..bb2d9e8 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,16 @@ "name": "passkit-generator", "version": "2.0.5", "description": "The easiest way to generate custom Apple Wallet passes in Node.js", - "main": "index.js", + "main": "lib/index.js", "scripts": { - "build": "npx tsc", + "build": "npm run build:src", + "build:all": "npm run build:src && npm run build:examples && npm run build:spec", + "build:src": "rm -rf ./lib && npx tsc -p tsconfig.dist.json", + "build:examples": "cd examples && npm run build", + "build:spec": "rm -rf ./spec/*.js && npx tsc", "prepublishOnly": "npm run build", - "test": "npm run build && jasmine spec/index.js" + "test": "npm run build:spec && npm run build:src && jasmine spec/index.js", + "example": "npm run build:src && npm --prefix examples run example" }, "author": "Alexander Patrick Cerutti", "license": "MIT", diff --git a/tsconfig.dist.json b/tsconfig.dist.json new file mode 100644 index 0000000..9db7c98 --- /dev/null +++ b/tsconfig.dist.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "lib" + }, + "include": [ + "src/**/*", + ] +}