diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 0f2a6d60..82612491 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -26,6 +26,9 @@ jobs: - name: Install Dependencies run: npm install + - name: Build Cosma + run: npm run build:back + - name: Install Cosma run: npm install . --global diff --git a/.gitignore b/.gitignore index c395eb27..196c5af6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ **/temp .DS_Store /build +/dist cosmoscope.html \ No newline at end of file diff --git a/controllers/autorecord.js b/controllers/autorecord.js index 76068525..9fd6e561 100644 --- a/controllers/autorecord.js +++ b/controllers/autorecord.js @@ -5,7 +5,7 @@ */ import Config from '../core/models/config.js'; -import makeRecord from './record.js'; +import createRecord from './create-record.js'; /** * Prompt config and pass record data @@ -33,7 +33,7 @@ function autorecord(title = '', type = 'undefined', tags = '', saveIdOnYmlFrontM saveIdOnYmlFrontMatter = config.opts['generate_id'] === 'always' || !!saveIdOnYmlFrontMatter; } - makeRecord(title, type, tags, config, saveIdOnYmlFrontMatter); + createRecord(title, type, tags, config, saveIdOnYmlFrontMatter); } export default autorecord; diff --git a/core/static/fake/config.yml b/core/static/fake/config.yml new file mode 100644 index 00000000..dbc9ef42 --- /dev/null +++ b/core/static/fake/config.yml @@ -0,0 +1,59 @@ +record_types: + undefined: + fill: '#858585' + stroke: '#858585' + super idea: + fill: '#1b9e77' + stroke: '#1b9e77' + concept: + fill: '#d95f02' + stroke: '#d95f02' + note: + fill: '#7570b3' + stroke: '#7570b3' + person: + fill: '#e7298a' + stroke: '#e7298a' + place: + fill: '#66a61e' + stroke: '#66a61e' + event: + fill: '#e6ab02' + stroke: '#e6ab02' + task: + fill: '#a6761d' + stroke: '#a6761d' + object: + fill: '#666666' + stroke: '#666666' + references: + fill: '#000' + stroke: '#000' +link_types: + undefined: + stroke: simple + color: '#e1e1e1' + g: + stroke: dotted + color: '#e1e1e1' + s: + stroke: dash + color: '#e1e1e1' +attraction_force: 500 +attraction_distance_max: 1400 +title: 'Test' +description: 'This cosmoscope was automatically generated with example data in order to test the functionality of the software.' +keywords: + - 'test' + - 'sample' +lang: 'en' +focus_max: 3 +node_size: 10 +record_metas: + - phone number + - begin + - end +chronological_record_meta: created +link_context: inline +references_as_nodes: false +references_type_label: 'references' \ No newline at end of file diff --git a/e2e/cypress.config.js b/e2e/cypress.config.js index 8e6d27b2..07547332 100644 --- a/e2e/cypress.config.js +++ b/e2e/cypress.config.js @@ -1,7 +1,7 @@ -import path from 'node:path'; -import { defineConfig } from 'cypress'; +const path = require('path'); +const { defineConfig } = require('cypress'); -const webpackConfig = defineConfig({ +module.exports = defineConfig({ downloadsFolder: path.join(__dirname, '../temp'), screenshotsFolder: path.join(__dirname, '../temp'), videosFolder: path.join(__dirname, '../temp'), @@ -14,5 +14,3 @@ const webpackConfig = defineConfig({ }, }, }); - -export default webpackConfig; diff --git a/package-lock.json b/package-lock.json index af897ed4..3d8d154d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "yaml": "^2.4.2" }, "bin": { - "cosma": "app.js" + "cosma": "dist/bundle.cjs" }, "devDependencies": { "@babel/core": "^7.24.5", @@ -37,6 +37,7 @@ "chai-fs": "^2.0.0", "cypress": "^13.9.0", "mocha": "^10.4.0", + "node-loader": "^2.0.0", "prettier": "3.2.5", "webpack": "^5.91.0", "webpack-cli": "^5.1.4", @@ -2921,6 +2922,15 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -4404,6 +4414,15 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "node_modules/emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -6119,6 +6138,20 @@ "node": ">=6.11.5" } }, + "node_modules/loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, + "dependencies": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + }, + "engines": { + "node": ">=8.9.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -6514,6 +6547,25 @@ "node": ">= 6.13.0" } }, + "node_modules/node-loader": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-loader/-/node-loader-2.0.0.tgz", + "integrity": "sha512-I5VN34NO4/5UYJaUBtkrODPWxbobrE4hgDqPrjB25yPkonFhCmZ146vTH+Zg417E9Iwoh1l/MbRs1apc5J295Q==", + "dev": true, + "dependencies": { + "loader-utils": "^2.0.0" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", diff --git a/package.json b/package.json index 40debbf3..aa3c9ff5 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,8 @@ "url": "https://github.com/graphlab-fr/cosma/issues" }, "main": "app.js", - "type": "module", "bin": { - "cosma": "app.js" + "cosma": "dist/bundle.cjs" }, "scripts": { "test:unit": "./node_modules/.bin/mocha 'core/test/**.js' --timeout 30000", @@ -22,7 +21,8 @@ "fake": "node ./core/index.js", "format": "./node_modules/.bin/prettier --write --list-different './**/**+(.js|.css)'", "man": "mkdir -p man && pandoc docs/user-manual.md -f markdown -t man -s --lua-filter man/manfilter.lua --include-before-body man/cosma.1.before --include-after-body man/cosma.1.after --metadata author=\"\" -o man/cosma.1", - "build": "./node_modules/.bin/webpack-cli build --config ./core/utils/webpack.config.js" + "build:front": "./node_modules/.bin/webpack-cli build --config ./core/utils/webpack.config.js", + "build:back": "./node_modules/.bin/webpack-cli build --config ./webpack.config.mjs --mode production" }, "contributors": [ "Arthur Perret", @@ -58,6 +58,7 @@ "chai-fs": "^2.0.0", "cypress": "^13.9.0", "mocha": "^10.4.0", + "node-loader": "^2.0.0", "prettier": "3.2.5", "webpack": "^5.91.0", "webpack-cli": "^5.1.4", diff --git a/webpack.config.mjs b/webpack.config.mjs new file mode 100644 index 00000000..38d90714 --- /dev/null +++ b/webpack.config.mjs @@ -0,0 +1,27 @@ +import webpack from 'webpack'; +import path from 'node:path'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default { + entry: path.resolve(__dirname, 'app.js'), + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'bundle.cjs', + }, + target: 'node', + module: { + rules: [ + { + test: /\.node$/, + use: 'node-loader', + }, + ], + }, + plugins: [new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true })], + resolve: { + extensions: ['.js'], + }, + mode: 'development', +};