Skip to content

Commit

Permalink
fix: build for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
clabroche committed Feb 11, 2024
1 parent 496f153 commit 0c07b41
Show file tree
Hide file tree
Showing 51 changed files with 260 additions and 264 deletions.
4 changes: 4 additions & 0 deletions .github/workflow-template-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ jobs:
git tag -fa v.latest -m "fix: set v.latest tag"
git push origin v.latest -f
echo "type=latest" >> $GITHUB_OUTPUT
cd servers/server
npm run build
cd dist
npm publish --access public
fi
- id: lerna
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/all-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ jobs:
git tag -fa v.latest -m "fix: set v.latest tag"
git push origin v.latest -f
echo "type=latest" >> $GITHUB_OUTPUT
cd servers/server
npm run build
cd dist
npm publish --access public
fi
- id: lerna
Expand Down
6 changes: 2 additions & 4 deletions common/check-monorepo/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Workspaces naming', () => {
const prefix = rootName.split('/').length === 2 // If is a scoped package
? rootName.split('/')[0]
: null;
if(workspace.packageJSON.name === '@iryu54/stack-monitor') return
if (prefix) {
expect(workspace.packageJSON.name).toBe(`${prefix}/${expectedName}`);
} else {
Expand Down Expand Up @@ -105,9 +104,8 @@ describe('Files', () => {
describe('Publish config', () => {
getWorkspaces().filter((workspace) => fse.existsSync(pathfs.resolve(workspace.path, 'package.json'))).forEach((workspace) => {
it(`${workspace.packageJSON.name} should be in private mode`, () => {
if(workspace.packageJSON.name === '@iryu54/stack-monitor') return
if(!workspace.packageJSON.private) {
expect(workspace.path+ '/package.json').toBe('to be in private mode')
if (!workspace.packageJSON.private) {
expect(`${workspace.path}/package.json`).toBe('to be in private mode');
}
});
it(`${workspace.packageJSON.name} should have a repository field`, () => {
Expand Down
4 changes: 2 additions & 2 deletions common/typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"version": "1.17.11",
"description": "",
"repository": "https://github.com/clabroche/stack-monitor",
"main": "src/index.d.ts",
"types": "src/index.ts",
"main": "src/index.ts",
"scripts": {
"test": "echo \"no test\""
},
"author": "",
"license": "ISC",
"types": "src/index.d.ts",
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*"
}
Expand Down
33 changes: 8 additions & 25 deletions common/typings/src/index.d.ts → common/typings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ export type NonFunctionPropertyNames<T> = {
export type NonFunctionPropertyNamesNumber<T> = {
[K in keyof T]: T[K] extends Function ? never : K;
}[keyof T];
// @ts-ignore
export type PartialPick<T,M> = Partial<Pick<T, M>>
export type FunctionProperties<T> = PartialPick<T, FunctionPropertyNames<T>>;
export type NonFunctionProperties<T> = PartialPick<T, NonFunctionPropertyNames<T>>;
export type NonFunctionPropertiesNumber<T> = Modify<NonFunctionProperties<T>, {[K in keyof NonFunctionProperties<T>]: number}>
export type NonFunctionPropertiesString<T> = Modify<NonFunctionProperties<T>, {[K in keyof NonFunctionProperties<T>]: string}>
export type NonFunctionPropertiesBoolean<T> = Modify<NonFunctionProperties<T>, {[K in keyof NonFunctionProperties<T>]: boolean}>
export type Modify<T, R> = Partial<Pick<T, Exclude<keyof T, keyof R,keyof S>> & R>
export type ToType<T> = NonFunctionProperties<T>;

export interface FieldDescriptior {
field: string,
Expand All @@ -27,6 +23,7 @@ type validation = (value: any, path: string) => {
type validationFactory = (...args: any) => validation

export type GenericFields<M> = {
// @ts-ignore
default: M = M
validation?: validation
hasMany?: string
Expand All @@ -40,17 +37,22 @@ export type Generic = {

type GeneratedClass<T, D, E> = {
new(schema: SchemaTransformed<T>): Instance<T,Partial<D>>;
// @ts-ignore
find: (filter: {filter: SchemaTransformed<T>, limit?: number, skip?: number, sort?: any, lookups?: any}) => Promise<Instance<T>[]>
// @ts-ignore
findOne: (filter: {filter: SchemaTransformed<T>, limit?: number, skip?: number, sort?: any, lookups?: any}) => Promise<Instance<T>>
// @ts-ignore
update: (filter: Instance<T>) => Promise<Instance<T>>
updateMany: (filter: SchemaTransformed<T>, set: SchemaTransformed<T>) => void
schema: T
schemaName: string
} & Partial<E> & {[key: string]: any}
type SchemaTransformed<M> = {
// @ts-ignore
[K in keyof M]?: M[K]['default']
}
type Instance<M, D> = SchemaTransformed<M> & {
// @ts-ignore
save: () => Promise<Instance<M>>
} & D
interface Option<C, D, E> {
Expand Down Expand Up @@ -82,29 +84,10 @@ type CustomFunctions<M> = {[key: string]: (this: M,...args: any) => any}
export interface Schema {
createSchema<M extends Generic ,C extends Generic, D extends CustomFunctions<Instance<M & C,Partial<D>>>, E extends CustomFunctions<F>, F extends GeneratedClass<M & C, D, E>>(name: string, schema: M, option?: Option<C, D, E>): F
}
// @ts-ignore
export type AnyObject<T = string> = Record<T, any>;


// export type FunctionPropertyNames<T> = {
// [K in keyof T]: T[K] extends Function ? K : never;
// }[keyof T];
// export type NonFunctionPropertyNames<T> = {
// [K in keyof T]: T[K] extends Function ? never : K;
// }[keyof T];
// export type NonFunctionPropertyNamesNumber<T> = {
// [K in keyof T]: T[K] extends Function ? never : K;
// }[keyof T];
// export type PartialPick<T, M extends keyof T> = Partial<Pick<T, M>>
// export type FunctionProperties<T> = PartialPick<T, FunctionPropertyNames<T>>;
// export type NonFunctionProperties<T> = PartialPick<T, NonFunctionPropertyNames<T>>;
// export type NonFunctionPropertiesNumber<T> = Modify<NonFunctionProperties<T>, { [K in keyof NonFunctionProperties<T>]: number }>
// export type NonFunctionPropertiesString<T> = Modify<NonFunctionProperties<T>, { [K in keyof NonFunctionProperties<T>]: string }>
// export type NonFunctionPropertiesBoolean<T> = Modify<NonFunctionProperties<T>, { [K in keyof NonFunctionProperties<T>]: boolean }>
// export type Modify<T, R> = Partial<Pick<T, Exclude<keyof T, keyof R>> & R>


//= ==== Root Types ==========
//= ==== Global Scripts ==========
import type {
GlobalScript as _Script,
ScriptStep as _ScriptStep,
Expand Down
13 changes: 13 additions & 0 deletions common/typings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"outFile": "dist/index.js",
"module": "AMD",
"noEmit": false,
"declaration": true,
},
"include": ["."],
"exclude": [
"node_modules/**/*",
"dist/**/*"
]
}
1 change: 0 additions & 1 deletion modules/bugs/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4"
Expand Down
2 changes: 1 addition & 1 deletion modules/bugs/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const router = express.Router();
const pathfs = require('path');
const { fork } = require('child_process');

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
module.exports = (stackMonitor) => {
router.get('/bugs/:service', async (req, res) => {
const service = stackMonitor.findService(req.params.service);
Expand Down
10 changes: 5 additions & 5 deletions modules/documentation/backend/Documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ async function walker(rootPath, pathToExplore, stripPath, leafs = []) {
return dir;
}

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const Documentation = (stackMonitor) => ({
/**
* @param {string} path
* @param {import('@clabroche/fronts-app/typings/export').Service} service
* @param {import('@clabroche/common-typings').Service} service
* @param {import('./index').Leaf[]} leafs
*/
getTree(path, service, leafs = []) {
Expand All @@ -52,7 +52,7 @@ const Documentation = (stackMonitor) => ({
},
/**
* @param {string} path
* @param {import('@clabroche/fronts-app/typings/export').Service} service
* @param {import('@clabroche/common-typings').Service} service
*/
async getFlatFiles(path, service) {
/** @type {import('./index').Leaf[]} */
Expand All @@ -63,14 +63,14 @@ const Documentation = (stackMonitor) => ({

/**
* @param {string} path
* @param {import('@clabroche/fronts-app/typings/export').Service} service
* @param {import('@clabroche/common-typings').Service} service
*/
readFile(path, service) {
return fse.readFile(pathfs.resolve(service.documentation, path), { encoding: 'utf-8' });
},
/**
* @param {string} path
* @param {import('@clabroche/fronts-app/typings/export').Service} service
* @param {import('@clabroche/common-typings').Service} service
* @param {string} page
*/
async writeFile(path, service, page) {
Expand Down
1 change: 0 additions & 1 deletion modules/documentation/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/bluebird": "^3.5.38",
"@types/express": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion modules/documentation/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');

const router = express.Router();

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
module.exports = (stackMonitor) => {
const { findService } = stackMonitor;

Expand Down
1 change: 0 additions & 1 deletion modules/finder/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/bluebird": "^3.5.38",
"@types/command-exists": "^1.2.3",
Expand Down
2 changes: 1 addition & 1 deletion modules/finder/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function pluginToUrl(plugin) {
return '';
}

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
const routes = (stackMonitor) => {
const {
getServices,
Expand Down
2 changes: 1 addition & 1 deletion modules/git/backend/Git.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { existsSync } = require('fs');
const pathfs = require('path');
const { execAsync, execAsyncWithoutErr } = require('../../../servers/server/helpers/exec');

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
const Git = (stackMonitor) => {
const { findService } = stackMonitor;
/** @param {import('../../../servers/server/models/Service')} service */
Expand Down
1 change: 0 additions & 1 deletion modules/git/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/command-exists": "^1.2.3",
"@types/express": "^4.17.21"
Expand Down
2 changes: 1 addition & 1 deletion modules/git/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');

const router = express.Router();

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
module.exports = (stackMonitor) => {
const { git } = stackMonitor;
router.get('/git/:service/graph', async (req, res) => {
Expand Down
1 change: 0 additions & 1 deletion modules/github/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4"
Expand Down
2 changes: 1 addition & 1 deletion modules/github/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let octokit = githubconf.GH_TOKEN
? new Octokit.Octokit({ auth: githubconf.GH_TOKEN })
: null;

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
module.exports = (stackMonitor) => {
const { findService } = stackMonitor;

Expand Down
2 changes: 1 addition & 1 deletion modules/global-scripts/backend/GlobalScripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const globalScripts = [];
/** @type {Record<string, TrackStep>} */
const currentScriptsByCommunicationId = {};

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
const GlobalScripts = (stackMonitor) => {
const { Socket } = stackMonitor;
return {
Expand Down
1 change: 0 additions & 1 deletion modules/global-scripts/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/express": "^4.17.21",
"@types/uuid": "^9.0.8",
Expand Down
2 changes: 1 addition & 1 deletion modules/global-scripts/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');

const router = express.Router();

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} Stack */
/** @param {import('@clabroche/common-typings').StackMonitor} Stack */
module.exports = (Stack) => {
const { globalScripts } = Stack;
router.get('/global-scripts/', async (req, res) => {
Expand Down
17 changes: 8 additions & 9 deletions modules/kanban/backend/Kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { v4 } = require('uuid');
const { getSave: _getSave } = require('./save');

/** @type {import('@clabroche/fronts-app/typings/export').StackMonitor | null} */
/** @type {import('@clabroche/common-typings').StackMonitor | null} */
let stackMonitor = null;

function getSave() {
Expand All @@ -11,9 +11,9 @@ function getSave() {
return { data, save };
}

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
class Board {
/** @param {Partial<import('@clabroche/fronts-app/typings').NonFunctionProperties<Board>>} board */
/** @param {Partial<import('@clabroche/common-typings').NonFunctionProperties<Board>>} board */
constructor(board = {}) {
/** @type {string} */
this.id = board.id || v4();
Expand Down Expand Up @@ -58,10 +58,9 @@ class Board {
return this.getColumns().find((c) => c?.id === id);
}

/** @param {Partial<import('@clabroche/fronts-app/typings').NonFunctionProperties<Column>>} column */
/** @param {Partial<import('@clabroche/common-typings').NonFunctionProperties<Column>>} column */
addColumn(column) {
const savedColumn = new Column({ ...column, boardId: this.id }).save();
console.log(savedColumn);
this.columnIds = [...new Set([...this.columnIds, savedColumn.id])];
this.save();
return savedColumn;
Expand All @@ -81,7 +80,7 @@ class Board {
}

class Column {
/** @param {Partial<import('@clabroche/fronts-app/typings').NonFunctionProperties<Column>>} column */
/** @param {Partial<import('@clabroche/common-typings').NonFunctionProperties<Column>>} column */
constructor(column = {}) {
/** @type {string} */
this.id = column.id || v4();
Expand Down Expand Up @@ -113,7 +112,7 @@ class Column {
return this.getCards().find((c) => c?.id === id);
}

/** @param {Partial<import('@clabroche/fronts-app/typings').NonFunctionProperties<Card>>} card */
/** @param {Partial<import('@clabroche/common-typings').NonFunctionProperties<Card>>} card */
addCard(card) {
const savedColumn = new Card({ ...card, boardId: this.boardId, columnId: this.id }).save();
this.cardIds = [...new Set([...this.cardIds, savedColumn.id])];
Expand Down Expand Up @@ -142,7 +141,7 @@ class Column {
}

class Card {
/** @param {Partial<import('@clabroche/fronts-app/typings').NonFunctionProperties<Card>>} card */
/** @param {Partial<import('@clabroche/common-typings').NonFunctionProperties<Card>>} card */
constructor(card = {}) {
/** @type {string} */
this.id = card.id || v4();
Expand Down Expand Up @@ -182,7 +181,7 @@ class Card {
return this;
}
}
/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} _stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} _stackMonitor */
const Kanban = (_stackMonitor) => {
stackMonitor = _stackMonitor;
return {
Expand Down
1 change: 0 additions & 1 deletion modules/kanban/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"devDependencies": {
"@clabroche/common-retrigger-all-build": "workspace:*",
"@clabroche/fronts-app": "workspace:*",
"@clabroche/modules-plugins-loader-front": "workspace:*",
"@types/express": "^4.17.21",
"@types/uuid": "^9.0.8"
Expand Down
2 changes: 1 addition & 1 deletion modules/kanban/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');

const router = express.Router();

/** @param {import('@clabroche/fronts-app/typings/export').StackMonitor} stackMonitor */
/** @param {import('@clabroche/common-typings').StackMonitor} stackMonitor */
module.exports = (stackMonitor) => {
const { Board } = require('./Kanban')(stackMonitor);

Expand Down
Loading

0 comments on commit 0c07b41

Please sign in to comment.