Changed build scripts for examples and main project

This commit is contained in:
Alexander Cerutti
2021-02-05 08:08:13 +01:00
parent 2e77f06950
commit 3290b697b4
11 changed files with 42 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ $ git clone https://github.com/alexandercerutti/passkit-generator.git;
$ cd passkit-generator && npm install; $ cd passkit-generator && npm install;
$ cd examples && npm install; $ cd examples && npm install;
$ npm run build; $ npm run build;
$ node <the-example-you-want-to-execute>.js $ npm run example <the-example-you-want-to-execute>.js
``` ```
Certificates paths in examples are linked to a folder `certificates` in the root of this project which is not provided. Certificates paths in examples are linked to a folder `certificates` in the root of this project which is not provided.

View File

@@ -1,5 +1,5 @@
import genRoute, { app } from "./webserver"; import genRoute, { app } from "./webserver";
import { createPass, createAbstractModel, AbstractModel } from ".."; import { createPass, createAbstractModel, AbstractModel } from "passkit-generator";
let abstractModel: AbstractModel; let abstractModel: AbstractModel;

View File

@@ -8,7 +8,7 @@
import app from "./webserver"; import app from "./webserver";
import fetch from "node-fetch"; import fetch from "node-fetch";
import { createPass } from ".."; import { createPass } from "passkit-generator";
app.all(async function manageRequest(request, response) { app.all(async function manageRequest(request, response) {
let passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); let passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");

View File

@@ -9,7 +9,7 @@
*/ */
import app from "./webserver"; import app from "./webserver";
import { createPass } from ".."; import { createPass } from "passkit-generator";
app.all(async function manageRequest(request, response) { app.all(async function manageRequest(request, response) {
const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); 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" format: "PKBarcodeFormatPDF417"
}, { }, {
message: "Thank you for using this package <3", message: "Thank you for using this package <3",
// @ts-expect-error
format: "PKBarcodeFormatMock44617" format: "PKBarcodeFormatMock44617"
}); });
} }
@@ -65,7 +66,7 @@ app.all(async function manageRequest(request, response) {
}); });
stream.pipe(response); stream.pipe(response);
} catch(err) { } catch (err) {
console.log(err); console.log(err);
response.set({ response.set({

View File

@@ -9,7 +9,7 @@
*/ */
import app from "./webserver"; import app from "./webserver";
import { createPass } from ".."; import { createPass } from "passkit-generator";
app.all(async function manageRequest(request, response) { app.all(async function manageRequest(request, response) {
if (!request.query.fn) { if (!request.query.fn) {
@@ -51,7 +51,7 @@ app.all(async function manageRequest(request, response) {
}); });
stream.pipe(response); stream.pipe(response);
} catch(err) { } catch (err) {
console.log(err); console.log(err);
response.set({ response.set({

View File

@@ -10,7 +10,7 @@
*/ */
import app from "./webserver"; import app from "./webserver";
import { createPass } from ".."; import { createPass } from "passkit-generator";
app.all(async function manageRequest(request, response) { app.all(async function manageRequest(request, response) {
let passName = "exampleBooking" + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); let passName = "exampleBooking" + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");

View File

@@ -5,7 +5,7 @@
*/ */
import app from "./webserver"; import app from "./webserver";
import { createPass } from ".."; import { createPass } from "passkit-generator";
app.all(async function manageRequest(request, response) { app.all(async function manageRequest(request, response) {
const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, ""); const passName = request.params.modelName + "_" + (new Date()).toISOString().split('T')[0].replace(/-/ig, "");

View File

@@ -5,7 +5,11 @@
"author": "Alexander P. Cerutti <cerutti.alexander@gmail.com>", "author": "Alexander P. Cerutti <cerutti.alexander@gmail.com>",
"license": "ISC", "license": "ISC",
"scripts": { "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": { "dependencies": {
"express": "^4.17.1", "express": "^4.17.1",

9
examples/tsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "build"
},
"exclude": [
"node_modules"
]
}

View File

@@ -2,11 +2,16 @@
"name": "passkit-generator", "name": "passkit-generator",
"version": "2.0.5", "version": "2.0.5",
"description": "The easiest way to generate custom Apple Wallet passes in Node.js", "description": "The easiest way to generate custom Apple Wallet passes in Node.js",
"main": "index.js", "main": "lib/index.js",
"scripts": { "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", "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", "author": "Alexander Patrick Cerutti",
"license": "MIT", "license": "MIT",

9
tsconfig.dist.json Normal file
View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "lib"
},
"include": [
"src/**/*",
]
}