@projectinvicta/nails 3.0.13 → 3.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +33 -0
- package/.github/workflows/release.yml +64 -0
- package/README.md +72 -10
- package/bin/lib/init.js +63 -32
- package/bin/test/test_init.sh +28 -20
- package/dist/Nails.js +12 -3
- package/dist/Nails.js.map +1 -1
- package/lib/Nails.ts +3 -3
- package/package.json +3 -2
- package/templates/default/bin/console.js +17 -0
- package/templates/default/config/db.js +1 -1
- package/templates/default/package-lock.json +925 -13
- package/templates/default/package.json +18 -5
- package/templates/default/spec/User.test.js +1 -1
- package/templates/default/src/app.jsx +7 -3
- package/templates/mcp/bin/console.js +17 -0
- package/templates/mcp/bin/promote.sh +20 -0
- package/templates/mcp/bin/rollout.sh +74 -0
- package/templates/mcp/bin/server.js +6 -0
- package/templates/mcp/bin/start.sh +16 -0
- package/templates/mcp/common/readme_fetcher.js +4 -0
- package/templates/mcp/config/db.js +11 -0
- package/templates/mcp/config/mimes.js +40 -0
- package/templates/mcp/config/routes.js +20 -0
- package/templates/mcp/config/service.js +45 -0
- package/templates/mcp/config/ssl/certificate.pem +22 -0
- package/templates/mcp/config/ssl/csr.csr +17 -0
- package/templates/mcp/config/ssl/key.pem +28 -0
- package/templates/mcp/config/ssl/private_key.pem +30 -0
- package/templates/mcp/config/ssl/public_key.pem +9 -0
- package/templates/mcp/package-lock.json +9960 -0
- package/templates/mcp/package.json +64 -0
- package/templates/mcp/server/controllers/home_controller.js +34 -0
- package/templates/mcp/server/controllers/mcp_controller.js +87 -0
- package/templates/mcp/server/controllers/users_controller.js +29 -0
- package/templates/mcp/server/models/Dog.js +8 -0
- package/templates/mcp/server/models/User.js +18 -0
- package/templates/mcp/server/views/home/index.ejs +14 -0
- package/templates/mcp/server/views/partials/javascripts.ejs +1 -0
- package/templates/mcp/server/views/partials/reactapp.ejs +1 -0
- package/templates/mcp/server/views/partials/styles.ejs +3 -0
- package/templates/mcp/spec/User.test.js +22 -0
- package/templates/mcp/spec/home_controller.test.js +28 -0
- package/templates/mcp/spec/setupTests.js +0 -0
- package/templates/mcp/vite.config.ts +42 -0
- package/templates/mobile/bin/console.js +17 -0
- package/templates/mobile/bin/promote.sh +20 -0
- package/templates/mobile/bin/rollout.sh +74 -0
- package/templates/mobile/bin/server.js +7 -0
- package/templates/mobile/bin/start.sh +16 -0
- package/templates/mobile/capacitor.config.ts +27 -0
- package/templates/mobile/common/constants.js +6 -0
- package/templates/mobile/common/readme_fetcher.js +4 -0
- package/templates/mobile/config/db.js +19 -0
- package/templates/mobile/config/mimes.js +59 -0
- package/templates/mobile/config/routes.js +38 -0
- package/templates/mobile/config/service.js +45 -0
- package/templates/mobile/config/ssl/certificate.pem +22 -0
- package/templates/mobile/config/ssl/csr.csr +17 -0
- package/templates/mobile/config/ssl/key.pem +28 -0
- package/templates/mobile/config/ssl/private_key.pem +30 -0
- package/templates/mobile/config/ssl/public_key.pem +9 -0
- package/templates/mobile/package.json +72 -0
- package/templates/mobile/src/AboutPage.jsx +9 -0
- package/templates/mobile/src/HomePage.jsx +9 -0
- package/templates/mobile/src/Layout.jsx +78 -0
- package/templates/mobile/src/ReadmePage.jsx +7 -0
- package/templates/mobile/src/app.jsx +33 -0
- package/templates/mobile/src/components/ReadmeLoader.jsx +13 -0
- package/templates/mobile/src/index.html +52 -0
- package/templates/mobile/src/styles/appstyles.css +3 -0
- package/templates/mobile/vite-mobile.config.ts +31 -0
- package/tests/bin/init.spec.js +70 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nails_app",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A basic nails application",
|
|
5
|
+
"main": "server.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": "./bin/start.sh",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"console": "export NAILS_RELEASE_STAGE=development TZ=America/Los_Angeles && node bin/console.js",
|
|
10
|
+
"console:dev": "export NAILS_RELEASE_STAGE=development TZ=America/Los_Angeles && node bin/console.js",
|
|
11
|
+
"console:test": "export NAILS_RELEASE_STAGE=test TZ=America/Los_Angeles && node bin/console.js",
|
|
12
|
+
"console:qa": "export NAILS_RELEASE_STAGE=qa TZ=America/Los_Angeles && node bin/console.js",
|
|
13
|
+
"console:staging": "export NAILS_RELEASE_STAGE=staging TZ=America/Los_Angeles && node bin/console.js",
|
|
14
|
+
"console:prod": "export NAILS_RELEASE_STAGE=production TZ=America/Los_Angeles && node bin/console.js",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"start": "export NAILS_RELEASE_STAGE=development TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
17
|
+
"start:dev": "export NAILS_RELEASE_STAGE=development TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
18
|
+
"start:test": "export NAILS_RELEASE_STAGE=test TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
19
|
+
"start:qa": "export NAILS_RELEASE_STAGE=qa TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
20
|
+
"start:staging": "export NAILS_RELEASE_STAGE=staging TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
21
|
+
"start:prod": "export NAILS_RELEASE_STAGE=production TZ=America/Los_Angeles && vite build && node bin/server.js",
|
|
22
|
+
"build": "vite build",
|
|
23
|
+
"rollout": "NAME=$npm_package_name ./bin/rollout.sh",
|
|
24
|
+
"promote": "./bin/promote.sh"
|
|
25
|
+
},
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "BSD",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/stantonwjones/nails-boilerplate/issues"
|
|
30
|
+
},
|
|
31
|
+
"config": {
|
|
32
|
+
"mongodbMemoryServer": {
|
|
33
|
+
"version": "latest"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"imports": {
|
|
37
|
+
"#models/*": "./server/models/*",
|
|
38
|
+
"#common/*": "./common/*",
|
|
39
|
+
"#config/*": "./config/*"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@projectinvicta/nails": "*",
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.4.0",
|
|
44
|
+
"zod": "^3.23.8",
|
|
45
|
+
"@mui/icons-material": "^7.3.1",
|
|
46
|
+
"@mui/material": "^7.3.1",
|
|
47
|
+
"@vitejs/plugin-legacy": "^6.1.1",
|
|
48
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
49
|
+
"react": "^19.1.0",
|
|
50
|
+
"react-dom": "^19.1.0",
|
|
51
|
+
"react-router-dom": "^7.7.0",
|
|
52
|
+
"sequelize": "^6.37.7",
|
|
53
|
+
"vite": "^6.3.5",
|
|
54
|
+
"chai-http": "*"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@capacitor/cli": "7.4.4",
|
|
58
|
+
"@emotion/react": "^11.14.0",
|
|
59
|
+
"@emotion/styled": "^11.14.1",
|
|
60
|
+
"@mui/types": "^7.4.5",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitest": "^3.2.4"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {Controller} from "@projectinvicta/nails";
|
|
2
|
+
|
|
3
|
+
export default class HomeController extends Controller {
|
|
4
|
+
/**
|
|
5
|
+
* You can define a local routing table directly in the controller.
|
|
6
|
+
* Local routes take precidence over global routes. All local routes
|
|
7
|
+
* are prefixed with the controller name unless they start with '/'.
|
|
8
|
+
* For example, in HomeController the following route:
|
|
9
|
+
*
|
|
10
|
+
* ["get", "data", {action: 'getData', json: true}],
|
|
11
|
+
*
|
|
12
|
+
* will accept GET requests to /home/data and respond with the json
|
|
13
|
+
* object returned by the getData function. If the route is changed to:
|
|
14
|
+
*
|
|
15
|
+
* ["get", "/data", {action: 'getData', json: true}],
|
|
16
|
+
*
|
|
17
|
+
* it will accept GET requests to /data instead. All local routes are
|
|
18
|
+
* implicitly routed to their respective parent controllers.
|
|
19
|
+
*/
|
|
20
|
+
routes = [
|
|
21
|
+
["get", "data", {action: 'getData', json: true}],
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
index(params, request, response) {
|
|
25
|
+
return {
|
|
26
|
+
title: "My first Nails Service",
|
|
27
|
+
welcome_message: "Welcome to Nails"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getData(params, request, response) {
|
|
32
|
+
return {testData: Math.floor(Math.random() * 10000000)}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import nails from "@projectinvicta/nails";
|
|
5
|
+
|
|
6
|
+
const server = new McpServer({
|
|
7
|
+
name: "Resonance MPC Server",
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// TODO: may want to use registerResource instead
|
|
12
|
+
// https://github.com/modelcontextprotocol/typescript-sdk?tab=readme-ov-file#resources
|
|
13
|
+
server.registerTool(
|
|
14
|
+
'generate_random',
|
|
15
|
+
{
|
|
16
|
+
title: 'Generate Random Numbers',
|
|
17
|
+
description: 'Tool to generate random numbers',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
numRandoms: z.number().int().describe("The number of random numbers to generate"),
|
|
20
|
+
type: z.enum(['integer', 'decimal']).describe("The type of random numbers to generate"),
|
|
21
|
+
scale: z.number().describe("The scale/maximum value for the numbers (e.g. 1, 10, 100, etc.)"),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async ({ numRandoms, type, scale }) => {
|
|
25
|
+
const numbers = [];
|
|
26
|
+
for (let i = 0; i < numRandoms; i++) {
|
|
27
|
+
let val = Math.random() * scale;
|
|
28
|
+
if (type === 'integer') {
|
|
29
|
+
val = Math.floor(val);
|
|
30
|
+
}
|
|
31
|
+
numbers.push(val);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
content: [{type: "text", text: JSON.stringify(numbers)}]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export default class MpcController extends nails.Controller {
|
|
41
|
+
json = true;
|
|
42
|
+
routes = [
|
|
43
|
+
['post', '/mcp'],
|
|
44
|
+
['get', '/mcp', {action: 'unsupportedMcpAction'}],
|
|
45
|
+
['delete', '/mcp', {action: 'unsupportedMcpAction'}],
|
|
46
|
+
['post', '/invoke/generate_random'],
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
async mcp(params, req, res) {
|
|
50
|
+
const transport = new StreamableHTTPServerTransport({
|
|
51
|
+
sessionIdGenerator: undefined,
|
|
52
|
+
});
|
|
53
|
+
res.on('close', () => {
|
|
54
|
+
console.log('Request closed');
|
|
55
|
+
transport.close();
|
|
56
|
+
server.close();
|
|
57
|
+
});
|
|
58
|
+
await server.connect(transport);
|
|
59
|
+
await transport.handleRequest(req, res, req.body);
|
|
60
|
+
// res.flushHeaders();
|
|
61
|
+
console.log("request handled");
|
|
62
|
+
console.log("Got here");
|
|
63
|
+
// res.end();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async unsupportedMcpAction(params, req, res) {
|
|
67
|
+
console.log(`Received ${req.method} MCP request`);
|
|
68
|
+
res.writeHead(405).end(JSON.stringify({
|
|
69
|
+
jsonrpc: "2.0",
|
|
70
|
+
error: {
|
|
71
|
+
code: -32000,
|
|
72
|
+
message: "Method not allowed."
|
|
73
|
+
},
|
|
74
|
+
id: null
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
async generate_random(params, request, response) {
|
|
80
|
+
const inputData = request.body;
|
|
81
|
+
return await server.invokeTool('generate_random', inputData);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function generateMcpToolExecutionResults() {
|
|
86
|
+
return {}; // Example results for MCP Tool execution
|
|
87
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {Controller} from "@projectinvicta/nails";
|
|
2
|
+
import User from "../models/User.js";
|
|
3
|
+
|
|
4
|
+
export default class UsersController extends Controller {
|
|
5
|
+
/**
|
|
6
|
+
* You can define a local routing table directly in the controller.
|
|
7
|
+
* Local routes take precidence over global routes. All local routes
|
|
8
|
+
* are prefixed with the controller name unless they start with '/'.
|
|
9
|
+
* For example, in HomeController the following route:
|
|
10
|
+
*
|
|
11
|
+
* ["get", "data", {action: 'getData', json: true}],
|
|
12
|
+
*
|
|
13
|
+
* will accept GET requests to /home/data and respond with the json
|
|
14
|
+
* object returned by the getData function. If the route is changed to:
|
|
15
|
+
*
|
|
16
|
+
* ["get", "/data", {action: 'getData', json: true}],
|
|
17
|
+
*
|
|
18
|
+
* it will accept GET requests to /data instead. All local routes are
|
|
19
|
+
* implicitly routed to their respective parent controllers.
|
|
20
|
+
*/
|
|
21
|
+
routes = [
|
|
22
|
+
["get", "./list"],
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
async list(params, request, response) {
|
|
26
|
+
return await User.findAll();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Model, DataTypes} from "@projectinvicta/nails";
|
|
2
|
+
import Dog from "./Dog.js";
|
|
3
|
+
|
|
4
|
+
export const schema = {
|
|
5
|
+
name: DataTypes.STRING,
|
|
6
|
+
verified: DataTypes.BOOLEAN,
|
|
7
|
+
email: DataTypes.STRING,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class User extends Model {};
|
|
11
|
+
|
|
12
|
+
export async function afterInitialize() {
|
|
13
|
+
// Add hooks here
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function afterInitializeAll() {
|
|
17
|
+
await User.hasMany(Dog);
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<%- include('../partials/styles'); -%>
|
|
4
|
+
<%- include('../partials/javascripts'); -%>
|
|
5
|
+
<title><%= title; %></title>
|
|
6
|
+
<script language="javascript">
|
|
7
|
+
window.WELCOME_MESSAGE = "<%= welcome_message %>";
|
|
8
|
+
</script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="AppRoot"></div>
|
|
12
|
+
<%- include('../partials/reactapp'); -%>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<script src="/public/js/client.js"></script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<script src="/public/dist/nails-react-app.js" type="module"></script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Nails from "@projectinvicta/nails";
|
|
2
|
+
import User from "#models/User";
|
|
3
|
+
import service_config from '#config/service.js';
|
|
4
|
+
import { beforeAll, test, expect } from "vitest";
|
|
5
|
+
|
|
6
|
+
const TEST_USER_EMAIL = "test@test.com";
|
|
7
|
+
const TEST_USER_NAME = "JohnDoe";
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
// Only initialize the Models.
|
|
10
|
+
await new Nails(service_config).initialized;
|
|
11
|
+
// await nails.MODELS.init( service_config );
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("Can create a User", async () => {
|
|
15
|
+
const user = await User.create({name: TEST_USER_NAME, email: TEST_USER_EMAIL});
|
|
16
|
+
|
|
17
|
+
expect(user.id).toBeDefined();
|
|
18
|
+
const retrievedUser = await User.findByPk(user.id);
|
|
19
|
+
expect(retrievedUser.id).toBeDefined();
|
|
20
|
+
expect(retrievedUser.name).toEqual(TEST_USER_NAME);
|
|
21
|
+
expect(retrievedUser.email).toEqual(TEST_USER_EMAIL);
|
|
22
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Nails from "@projectinvicta/nails";
|
|
2
|
+
// import chai from 'chai';
|
|
3
|
+
import {default as chaiHttp, request} from 'chai-http';
|
|
4
|
+
import service_config from '../config/service.js';
|
|
5
|
+
import { chai, beforeAll, test, expect } from "vitest";
|
|
6
|
+
|
|
7
|
+
let express_app;
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
// Initialize the application and start the server
|
|
11
|
+
await new Nails( service_config ).startServer();
|
|
12
|
+
express_app = Nails.application;
|
|
13
|
+
chai.use(chaiHttp);
|
|
14
|
+
chai.should();
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
test("GET / renders the home page", async () => {
|
|
19
|
+
return await new Promise((resolve, reject) => {
|
|
20
|
+
request.execute(express_app)
|
|
21
|
+
.get('/')
|
|
22
|
+
.end((err, res) => {
|
|
23
|
+
res.should.have.status(200);
|
|
24
|
+
expect(res.text).toContain("Welcome to Nails");
|
|
25
|
+
resolve();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
import { defineConfig } from 'vite'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
publicDir: false,
|
|
10
|
+
define: {
|
|
11
|
+
'process.env': {}
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
react(),
|
|
15
|
+
],
|
|
16
|
+
test: {
|
|
17
|
+
globals: true,
|
|
18
|
+
// environment: 'jsdom',
|
|
19
|
+
// setupFiles: './spec/setupTests.js',
|
|
20
|
+
env: {
|
|
21
|
+
NAILS_RELEASE_STAGE: "test",
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
build: {
|
|
25
|
+
lib: {
|
|
26
|
+
entry: './src/app.jsx', // Your library's main entry file
|
|
27
|
+
name: 'NailsReactApp',
|
|
28
|
+
fileName: 'nails-react-app',
|
|
29
|
+
},
|
|
30
|
+
outDir: './public/dist',
|
|
31
|
+
},
|
|
32
|
+
esbuild: {
|
|
33
|
+
minifyIdentifiers: false,
|
|
34
|
+
keepNames: true,
|
|
35
|
+
},
|
|
36
|
+
resolve: {
|
|
37
|
+
alias: {
|
|
38
|
+
'@common': path.resolve(__dirname, './common'), // Alias '@' to the 'common' directory
|
|
39
|
+
'@server': path.resolve(__dirname, './server'), // Alias '@' to the 'server' directory
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import repl from 'repl';
|
|
2
|
+
import Nails from '@projectinvicta/nails';
|
|
3
|
+
import service_config from '../config/service.js';
|
|
4
|
+
|
|
5
|
+
console.log("Initializing Nails for REPL...");
|
|
6
|
+
|
|
7
|
+
const nails = new Nails(service_config);
|
|
8
|
+
await nails.initialized;
|
|
9
|
+
|
|
10
|
+
console.log("Nails initialized!");
|
|
11
|
+
console.log("The 'nails' instance (and nails.Models) is available in the context.");
|
|
12
|
+
|
|
13
|
+
const replServer = repl.start({
|
|
14
|
+
prompt: 'nails> '
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
replServer.context.nails = nails;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version=$1
|
|
2
|
+
if [ "$version" == "" ]; then
|
|
3
|
+
version="live"
|
|
4
|
+
fi
|
|
5
|
+
|
|
6
|
+
if [ "$version" != "live" ] &&
|
|
7
|
+
[ "$version" != "development" ] &&
|
|
8
|
+
[ "$version" != "staging_qa" ] &&
|
|
9
|
+
[ "$version" != "staging_prod" ] &&
|
|
10
|
+
[ "$version" != "production" ]; then
|
|
11
|
+
echo "$version is not a valid version"
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
# TODO: make sure we're on the master branch
|
|
16
|
+
git pull origin master
|
|
17
|
+
git tag -d $version
|
|
18
|
+
git push origin --delete $version
|
|
19
|
+
git tag $version
|
|
20
|
+
git push origin $version
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# make sure no one can run the script on their local machine
|
|
2
|
+
stage=$1
|
|
3
|
+
if [ "$stage" = "" ]; then
|
|
4
|
+
stage="live"
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
if [ "$stage" != "live" ] &&
|
|
8
|
+
[ "$stage" != "development" ] &&
|
|
9
|
+
[ "$stage" != "staging_qa" ] &&
|
|
10
|
+
[ "$stage" != "staging_prod" ] &&
|
|
11
|
+
[ "$stage" != "production" ]; then
|
|
12
|
+
echo "$stage is not a valid release stage"
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
current_hostname=$(hostname)
|
|
17
|
+
|
|
18
|
+
# TODO: find a better way to do this rather than listing them all out. Maybe some kind of dynamic list checking.
|
|
19
|
+
com_suffix=".com"
|
|
20
|
+
dev_suffix=".dev"
|
|
21
|
+
app_suffix=".app"
|
|
22
|
+
net_suffix=".net"
|
|
23
|
+
org_suffix=".org"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if [[ $current_hostname != *$com_suffix &&
|
|
27
|
+
$current_hostname != *$dev_suffix &&
|
|
28
|
+
$current_hostname != *$app_suffix &&
|
|
29
|
+
$current_hostname != *$net_suffix &&
|
|
30
|
+
$current_hostname != *$org_suffix ]]; then
|
|
31
|
+
echo "This script cannot be run on your local machine and must be run on a server"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
echo "Running checkout_live.sh version $stage on `date`"
|
|
36
|
+
|
|
37
|
+
# check if the repo is up to date by comparing hashes for the live tag
|
|
38
|
+
remote_hash=$(git ls-remote --tags origin "$stage" | awk '{ print $1 }')
|
|
39
|
+
local_hash=$(git rev-list -n 1 $stage)
|
|
40
|
+
|
|
41
|
+
# get the latest updates from the repo if out of date
|
|
42
|
+
if [ $remote_hash != $local_hash ]; then
|
|
43
|
+
date=`date`
|
|
44
|
+
echo "Checkout $NAME running at: $date"
|
|
45
|
+
echo "Checkout $NAME running at: $date" 1>&2 # write date to stderr as well
|
|
46
|
+
echo "`dirname $0`"
|
|
47
|
+
echo "`dirname $0`" 1>&2
|
|
48
|
+
git fetch --all --tags --force
|
|
49
|
+
git checkout tags/$stage
|
|
50
|
+
npm install
|
|
51
|
+
else
|
|
52
|
+
echo "Repository is not out of date. Exiting..."
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# TODO: add conditional when real test added
|
|
57
|
+
|
|
58
|
+
# test
|
|
59
|
+
npm test # currently an echo noop
|
|
60
|
+
|
|
61
|
+
# restart parkway
|
|
62
|
+
/usr/sbin/service $NAME-$stage restart
|
|
63
|
+
|
|
64
|
+
changelog=`git log $local_hash..$remote_hash --oneline`
|
|
65
|
+
|
|
66
|
+
# send email
|
|
67
|
+
user=$(whoami)
|
|
68
|
+
message="The latest $NAME changes have been deployed to $stage at $date by $user\n$changelog"
|
|
69
|
+
recipient="eng@projectinvicta.com"
|
|
70
|
+
subject="Automated deploy of $NAME: $stage"
|
|
71
|
+
echo $message | mail -s "$subject" $recipient
|
|
72
|
+
echo "Mail sent"
|
|
73
|
+
|
|
74
|
+
exit 0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
SCRIPT_DIR=$(dirname "$0")
|
|
2
|
+
echo "Script directory (relative): $SCRIPT_DIR"
|
|
3
|
+
|
|
4
|
+
COMMAND=$1
|
|
5
|
+
if [[ -z "${COMMAND}" ]]; then
|
|
6
|
+
COMMAND=start
|
|
7
|
+
else
|
|
8
|
+
echo "COMMAND is NOT empty."
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
SCRIPT_PATH=$(readlink -f "$0")
|
|
13
|
+
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
|
|
14
|
+
echo "Script directory (absolute, resolved): $SCRIPT_DIR"
|
|
15
|
+
|
|
16
|
+
npm --prefix=$SCRIPT_DIR/.. run $COMMAND -- $2 $3 $4 $5 $6 $7 $8 $9
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CapacitorConfig } from '@capacitor/cli';
|
|
2
|
+
|
|
3
|
+
const config: CapacitorConfig = {
|
|
4
|
+
appId: 'com.nailsapp',
|
|
5
|
+
appName: 'Nails',
|
|
6
|
+
webDir: 'mobile-dist',
|
|
7
|
+
server: {
|
|
8
|
+
// url: 'https://development.parkwaysapp.com',
|
|
9
|
+
// androidScheme: "android",
|
|
10
|
+
// hostname: 'development.parkwaysapp.com',
|
|
11
|
+
// cleartext: true,
|
|
12
|
+
// allowNavigation: [
|
|
13
|
+
// '*',
|
|
14
|
+
// "https://accounts.google.com/*",
|
|
15
|
+
// "accounts.google.com",
|
|
16
|
+
// "https://oauthreceiver.parkwaysapp.com",
|
|
17
|
+
// "*.parkwaysapp.com",
|
|
18
|
+
// "https://oauthreceiver.parkwaysapp.com/*"],
|
|
19
|
+
}
|
|
20
|
+
// appendUserAgent: "ANDROID_CAPACITOR",
|
|
21
|
+
// android: {
|
|
22
|
+
// allowMixedContent: true,
|
|
23
|
+
// appendUserAgent: "ANDROID_CAPACITOR",
|
|
24
|
+
// }
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
let DB_ADDRESS = process.env.NAILS_SQLITE_DB_FILE;
|
|
2
|
+
if (!DB_ADDRESS) DB_ADDRESS = 'sqlite://' + import.meta.dirname + '/development.db';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
/** Mongoose Connector */
|
|
6
|
+
// connector: 'mongoose_connector.js',
|
|
7
|
+
// url: 'mongodb://localhost',
|
|
8
|
+
// port: '27017',
|
|
9
|
+
|
|
10
|
+
/** Mongoose Memory Server Connector */
|
|
11
|
+
// connector: 'mongoose_mem_connector.js',
|
|
12
|
+
// database: 'development',
|
|
13
|
+
|
|
14
|
+
/** Sequelize Connector */
|
|
15
|
+
connector: 'sequelize_connector.js',
|
|
16
|
+
address: process.env.NAILS_RELEASE_STAGE == 'test'
|
|
17
|
+
? 'sqlite:///:memory:'
|
|
18
|
+
: DB_ADDRESS,
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file uses file extensions in the request to determine
|
|
3
|
+
* the type of an asset and, therefore, where it can be found
|
|
4
|
+
* in the file system.
|
|
5
|
+
*
|
|
6
|
+
* Currently, the supported types are: 'js', 'css', 'html',
|
|
7
|
+
* 'img'
|
|
8
|
+
* TODO: Add supported types pdf ( or document ), and video
|
|
9
|
+
* TODO: move this file into nails. Too annoying for the dev
|
|
10
|
+
* to see and they shouldn't need to have to change it
|
|
11
|
+
*/
|
|
12
|
+
/*
|
|
13
|
+
var mimes = {
|
|
14
|
+
// <ext>: '<type>'
|
|
15
|
+
js: 'js',
|
|
16
|
+
jpg: 'image',
|
|
17
|
+
css: 'css',
|
|
18
|
+
html: 'html'
|
|
19
|
+
};
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
html: {
|
|
24
|
+
type: 'page',
|
|
25
|
+
contentType: 'text/html'
|
|
26
|
+
},
|
|
27
|
+
js: {
|
|
28
|
+
type: 'script', // the type of the script,
|
|
29
|
+
contentType: 'application/javascript' // Header info
|
|
30
|
+
},
|
|
31
|
+
css: {
|
|
32
|
+
type: 'style',
|
|
33
|
+
contentType: 'text/css'
|
|
34
|
+
},
|
|
35
|
+
ico: {
|
|
36
|
+
type: 'image',
|
|
37
|
+
contentType: 'image/x-icon'
|
|
38
|
+
},
|
|
39
|
+
jpg: {
|
|
40
|
+
type: 'image',
|
|
41
|
+
contentType: 'image/jpeg'
|
|
42
|
+
},
|
|
43
|
+
png: {
|
|
44
|
+
type: 'image',
|
|
45
|
+
contentType: 'image/png'
|
|
46
|
+
},
|
|
47
|
+
pdf: {
|
|
48
|
+
type: 'document',
|
|
49
|
+
contentType: 'application/pdf'
|
|
50
|
+
},
|
|
51
|
+
xml: {
|
|
52
|
+
type: 'data',
|
|
53
|
+
contentType: 'text/xml'
|
|
54
|
+
},
|
|
55
|
+
json: {
|
|
56
|
+
type: 'data',
|
|
57
|
+
contentType: 'application/json'
|
|
58
|
+
}
|
|
59
|
+
}
|