not-node 6.1.1 → 6.1.3

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.
Files changed (53) hide show
  1. package/.env +2 -2
  2. package/.vscode/launch.json +19 -0
  3. package/bin/not-cli.mjs +49 -13
  4. package/package.json +1 -1
  5. package/src/cli/readers/hostname.mjs +1 -1
  6. package/src/cli/readers/user.mjs +8 -1
  7. package/src/init/lib/modules.js +1 -2
  8. package/src/init/lib/routes.js +4 -1
  9. package/src/metas.js +4 -3
  10. package/tmpl/files/app/app.ejs +3 -0
  11. package/tmpl/files/app/routes/index.ejs +29 -31
  12. package/tmpl/files/app/views/parts/header.android.ejs +6 -7
  13. package/tmpl/files/app/views/parts/header.ios.ejs +5 -5
  14. package/tmpl/files/app/views/parts/menu.ejs +1 -1
  15. package/tmpl/files/app/views/parts/overview.ejs +1 -1
  16. package/playground/.babelrc +0 -11
  17. package/playground/.eslintignore +0 -4
  18. package/playground/.eslintrc.json +0 -23
  19. package/playground/app/front/build.env.js +0 -15
  20. package/playground/app/front/index.!.js +0 -64
  21. package/playground/app/front/rollup.!.js +0 -70
  22. package/playground/app/front/src/admin/main/index.js +0 -45
  23. package/playground/app/front/src/client/main/index.js +0 -45
  24. package/playground/app/front/src/common/index.js +0 -39
  25. package/playground/app/front/src/common/ncInit.js +0 -18
  26. package/playground/app/front/src/common/ws.client.main.js +0 -35
  27. package/playground/app/front/src/guest/main/index.js +0 -34
  28. package/playground/app/front/src/root/main/index.js +0 -45
  29. package/playground/app/front/src/user/main/index.js +0 -45
  30. package/playground/app/server/app.js +0 -22
  31. package/playground/app/server/config/common.json +0 -99
  32. package/playground/app/server/config/development.json +0 -34
  33. package/playground/app/server/config/production.json +0 -34
  34. package/playground/app/server/config/stage.json +0 -34
  35. package/playground/app/server/index.js +0 -20
  36. package/playground/app/server/routes/index.js +0 -36
  37. package/playground/app/server/routes/site.js +0 -71
  38. package/playground/app/server/views/admin/foot.pug +0 -1
  39. package/playground/app/server/views/admin/head.pug +0 -7
  40. package/playground/app/server/views/admin/menu.pug +0 -2
  41. package/playground/app/server/views/admin.pug +0 -19
  42. package/playground/app/server/views/dashboard.pug +0 -20
  43. package/playground/app/server/views/index.pug +0 -15
  44. package/playground/app/server/views/parts/header.android.pug +0 -7
  45. package/playground/app/server/views/parts/header.ios.pug +0 -5
  46. package/playground/app/server/views/parts/header.pug +0 -18
  47. package/playground/app/server/views/parts/menu.pug +0 -1
  48. package/playground/app/server/views/parts/overview.pug +0 -2
  49. package/playground/app/server/ws/auth.js +0 -41
  50. package/playground/app/server/ws/index.js +0 -84
  51. package/playground/bin/build.sh +0 -8
  52. package/playground/package.json +0 -85
  53. package/playground/project.manifest.json +0 -37
package/.env CHANGED
@@ -5,8 +5,8 @@ INIT_ROOT_USERNAME=root
5
5
  INIT_ROOT_EMAIL=admin@appmon.ru
6
6
  INIT_ROOT_PASSWORD=tester
7
7
  db__mongoose__uri=mongodb://localhost/reporter?authSource=reporter
8
- db__mongoose__options__user=reporter.production
9
- db__mongoose__options__pass=production.reporter
8
+ db__mongoose__options__user=reporter
9
+ db__mongoose__options__pass=developer
10
10
  db__mongoose__options__db=reporter
11
11
  db__mongoose__options__host=localhost
12
12
  db__mongoose__options__authSource=reporter
@@ -0,0 +1,19 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "address": "127.0.0.1",
9
+ "localRoot": "${workspaceFolder}/playground",
10
+ "name": "Debug playground",
11
+ "port": 3031,
12
+ "sourceMaps": true,
13
+ "remoteRoot": "${workspaceFolder}/playground",
14
+ "request": "attach",
15
+ "skipFiles": ["<node_internals>/**"],
16
+ "type": "node"
17
+ }
18
+ ]
19
+ }
package/bin/not-cli.mjs CHANGED
@@ -8,7 +8,7 @@ import { isAbsolute, resolve, join } from "node:path";
8
8
 
9
9
  import { copyFile, constants, mkdir, writeFile } from "node:fs/promises";
10
10
 
11
- import { cwd, stdout, stderr } from "node:process";
11
+ import { cwd } from "node:process";
12
12
  const CWD = cwd();
13
13
  import { spawn } from "node:child_process";
14
14
 
@@ -326,6 +326,51 @@ async function createBootstrapFrontModule(modules_dir, config) {
326
326
  }
327
327
  }
328
328
 
329
+ function installPackages(opts) {
330
+ return new Promise((resolve, reject) => {
331
+ console.log("installing packages...");
332
+ let npmInstall = spawn(`npm`, ["i"], { cwd: opts.dir });
333
+
334
+ npmInstall.stderr.on("data", (data) => {
335
+ console.error(data.toString());
336
+ });
337
+ npmInstall.on("exit", (code) => {
338
+ if (code == 0) {
339
+ resolve();
340
+ } else {
341
+ reject(`NPM install exited with code ${code}`);
342
+ }
343
+ });
344
+ });
345
+ }
346
+
347
+ function buildClientSideScripts(opts) {
348
+ return new Promise((resolve, reject) => {
349
+ console.log("building client side scripts...");
350
+ let npmInstall = spawn(`npm`, ["run", "build"], { cwd: opts.dir });
351
+
352
+ npmInstall.stderr.on("data", (data) => {
353
+ console.error(data.toString());
354
+ });
355
+ npmInstall.on("exit", (code) => {
356
+ if (code == 0) {
357
+ resolve();
358
+ } else {
359
+ reject(`npm run build job exited with code ${code}`);
360
+ }
361
+ });
362
+ });
363
+ }
364
+
365
+ function postStartupInstructions(opts) {
366
+ console.log(
367
+ "Generation of source code, configurations and installation of packages successfully finished."
368
+ );
369
+ console.log(
370
+ `To start server navigate to directory '${opts.dir}' (cd '${opts.dir}') and run 'npm start'`
371
+ );
372
+ }
373
+
329
374
  program
330
375
  .command("create")
331
376
  .addOption(
@@ -368,18 +413,9 @@ program
368
413
  await createBootstrapFrontModule(PATH_MODULES_FRONT, AppConfig);
369
414
  }
370
415
  console.log(`cd '${opts.dir}' && npm i`);
371
- let npmInstall = spawn(`npm`, ["i"], { cwd: opts.dir });
372
- npmInstall.stdout.on("data", (data) => {
373
- console.log(data.toString());
374
- });
375
-
376
- npmInstall.stderr.on("data", (data) => {
377
- console.error(data.toString());
378
- });
379
-
380
- npmInstall.on("exit", (code) => {
381
- console.log(`NPM install exited with code ${code}`);
382
- });
416
+ await installPackages(opts);
417
+ await buildClientSideScripts(opts);
418
+ postStartupInstructions(opts);
383
419
  });
384
420
 
385
421
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.1.1",
3
+ "version": "6.1.3",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- const DEFAULT_HOST = "https://localhost";
1
+ const DEFAULT_HOST = "localhost";
2
2
  export default (inquirer) => {
3
3
  return inquirer.prompt([
4
4
  {
@@ -1,3 +1,10 @@
1
+ const DEFAULT_CONFIG = {
2
+ restrict: {
3
+ registration: false,
4
+ },
5
+ tokenTTL: 3600,
6
+ };
7
+
1
8
  function collectRestrictions(inquirer) {
2
9
  return inquirer.prompt([
3
10
  {
@@ -56,7 +63,7 @@ export default (inquirer) => {
56
63
  if (answer.enabled) {
57
64
  return collectData(inquirer);
58
65
  } else {
59
- return false;
66
+ return DEFAULT_CONFIG;
60
67
  }
61
68
  });
62
69
  };
@@ -1,6 +1,5 @@
1
1
  module.exports = class InitModules {
2
2
  async run({ master }) {
3
- master.getApp().execInModules("initialize", master);
4
- master.getApp().execInModules("registerPagesRoutes", master);
3
+ await master.getApp().execInModules("initialize", master);
5
4
  }
6
5
  };
@@ -59,9 +59,12 @@ module.exports = class InitRoutes {
59
59
 
60
60
  async run({ master, config, options }) {
61
61
  log.info("Setting up routes...");
62
+ //pages rendering
63
+ await master.getApp().execInModules("registerPagesRoutes", master);
64
+ //api first
62
65
  master.getApp().expose(master.getServer());
66
+ //user defined pages
63
67
  require(options.routesPath)(master.getServer(), master.getApp());
64
-
65
68
  master.getServer().use(serveStatic(config.get("staticPath")));
66
69
  master.getServer().use(options.indexRoute);
67
70
  master.getServer().use(
package/src/metas.js CHANGED
@@ -1,11 +1,12 @@
1
1
  const Auth = require("./auth"),
2
- Env = require("./env"),
2
+ notAppIdentity = require("./identity"),
3
3
  notStyler = require("./styler"),
4
4
  config = require("not-config").createReader();
5
5
 
6
6
  function getRole(req) {
7
- if (Auth.isUser(req) && req.user) {
8
- return req.user.getPrimaryRole(Env.getEnv("rolesPriority"));
7
+ const identity = new notAppIdentity(req);
8
+ if (identity.isUser()) {
9
+ return identity.getRole();
9
10
  } else {
10
11
  return Auth.DEFAULT_USER_ROLE_FOR_GUEST;
11
12
  }
@@ -1,5 +1,7 @@
1
1
  const notNode = require("not-node");
2
2
 
3
+ const InitIdentityTokens = require("not-user").InitIdentityTokens;
4
+
3
5
  const Init = require("not-node").Init,
4
6
  path = require("path"),
5
7
  manifest = require("./../../project.manifest.json");
@@ -15,6 +17,7 @@ module.exports = () => {
15
17
  const additional = {
16
18
  pre({ initSequence }) {
17
19
  initSequence.remove("InitMonitoring");
20
+ initSequence.insert(InitIdentityTokens);
18
21
  },
19
22
  };
20
23
 
@@ -1,36 +1,34 @@
1
- const
2
- notNode = require('not-node'),
3
- Auth = require('not-node').Auth,
4
- siteRouter = require('./site');
1
+ const notNode = require("not-node"),
2
+ { Auth, notAppIdentity } = require("not-node"),
3
+ siteRouter = require("./site");
5
4
 
6
5
  module.exports = (web) => {
6
+ web.get("/api/manifest", function (req, res) {
7
+ notNode.notHeadersStyler.get()(req, res);
8
+ res.status(200).json(notNode.Application.getManifest(req));
9
+ });
7
10
 
8
- web.get('/api/manifest', function(req, res) {
9
- notNode.notHeadersStyler.get()(req,res);
10
- res.status(200).json(notNode.Application.getManifest(req));
11
- });
12
-
13
-
14
- web.get('/', (req, res, next) => {
15
- if (Auth.isUser(req)) {
16
- res.redirect('/dashboard');
17
- }else{
18
- next();
19
- }
20
- },
21
- siteRouter.index
22
- );
23
-
24
-
25
- web.get('/dashboard*',
26
- (req, res, next) => {
27
- if (Auth.isUser(req)) {
28
- next();
29
- } else {
30
- res.redirect('/login');
31
- }
32
- },
33
- siteRouter.dashboard
34
- );
11
+ web.get(
12
+ "/",
13
+ (req, res, next) => {
14
+ if (new notAppIdentity(req).isUser()) {
15
+ res.redirect("/dashboard");
16
+ } else {
17
+ next();
18
+ }
19
+ },
20
+ siteRouter.index
21
+ );
35
22
 
23
+ web.get(
24
+ "/dashboard*",
25
+ (req, res, next) => {
26
+ if (new notAppIdentity(req).isUser()) {
27
+ next();
28
+ } else {
29
+ res.redirect("/login");
30
+ }
31
+ },
32
+ siteRouter.dashboard
33
+ );
36
34
  };
@@ -1,7 +1,6 @@
1
-
2
- <!-- Android -->
3
- meta(name="theme-color" content="#48c774")
4
- meta(name="color-scheme" content="light")
5
- meta(name="mobile-web-app-capable" content="yes")
6
- link(rel="stylesheet" href=host+"/front/"+role+".css")
7
- link(rel="stylesheet" href=host+"/assets/font-awesome.min.css")
1
+ <!-- Android -->
2
+ meta(name="theme-color" content="#48c774")
3
+ meta(name="color-scheme" content="light")
4
+ meta(name="mobile-web-app-capable" content="yes")
5
+ link(rel="stylesheet" href=host+"/front/"+role+".css")
6
+ link(rel="stylesheet" href=host+"/assets/font-awesome.min.css")
@@ -1,5 +1,5 @@
1
- <!-- iOS -->
2
- meta(name="apple-mobile-web-app-title" content=title)
3
- meta(name="apple-mobile-web-app-capable" content="yes")
4
- meta(name="apple-mobile-web-app-status-bar-style" content="#48c774")
5
- link(rel="apple-touch-icon" href="./img/icons/icon-512.png")
1
+ <!-- iOS -->
2
+ meta(name="apple-mobile-web-app-title" content=title)
3
+ meta(name="apple-mobile-web-app-capable" content="yes")
4
+ meta(name="apple-mobile-web-app-status-bar-style" content="#48c774")
5
+ link(rel="apple-touch-icon" href="./img/icons/icon-512.png")
@@ -1 +1 @@
1
- nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
1
+ nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
@@ -1,2 +1,2 @@
1
1
  div(class="is-success is-fullheight")
2
- p Story of another little side project.
2
+ p Story of another little side project.
@@ -1,11 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env"],
3
- "plugins": [
4
- [
5
- "@babel/plugin-proposal-class-properties",
6
- {
7
- "loose": true
8
- }
9
- ]
10
- ]
11
- }
@@ -1,4 +0,0 @@
1
- node_modules/**
2
- coverage/**
3
- app/static/**
4
- app/server/views/**
@@ -1,23 +0,0 @@
1
- {
2
- "parserOptions": {
3
- "ecmaVersion": 10,
4
- "sourceType": "module"
5
- },
6
- "env": {
7
- "browser": true,
8
- "es6": true,
9
- "node": true,
10
- "mongo": true,
11
- "mocha": true
12
- },
13
- "globals": {
14
- "ENV": true
15
- },
16
- "extends": "eslint:recommended",
17
- "rules": {
18
- "indent": "error",
19
- "linebreak-style": ["error", "unix"],
20
- "semi": ["error", "always"],
21
- "no-useless-escape": [0]
22
- }
23
- }
@@ -1,15 +0,0 @@
1
-
2
- let replaceSets = {
3
- development: {},
4
- production: {},
5
- stage: {},
6
- };
7
-
8
- let babelOn = () => {
9
- return ['production', 'stage', 'development'].indexOf(process.env.NODE_ENV) > -1;
10
- };
11
-
12
- export {
13
- babelOn,
14
- replaceSets
15
- };
@@ -1,64 +0,0 @@
1
-
2
-
3
- import {
4
- Frame
5
- } from 'not-bulma';
6
-
7
- const {notCommon, notApp, COMPONENTS} = Frame;
8
-
9
- notCommon.register('backlog', true);
10
- window.dumpBacklog = notCommon.dumpBacklog.bind(notCommon);
11
-
12
- let appDefaultOptions = {
13
- manifestURL: '/api/manifest',
14
- router: {
15
- root: '/',
16
- manifest: [],
17
- index: ''
18
- },
19
- language: 'ru',
20
- crud: {
21
- navigateBackAfter: ['create', 'update', 'delete']
22
- },
23
- modules: {
24
- user: {
25
- redirectTimout: 1000,
26
- afterLoginURL: '/dashboard',
27
- loginForm: {
28
- modes: [
29
- 'login',
30
- 'requestLoginCodeOnEmail',
31
- 'loginByCode'
32
- ]
33
- },
34
- loginFormContainerSelector: '.main-container',
35
- restoreFormContainerSelector: '.main-container',
36
- registerFormContainerSelector: '.main-container'
37
- }
38
- }
39
- };
40
-
41
- let services = {}, uis = {}, wsc = {}, fields = {};
42
-
43
- <% for(var i = 0; i < mods.length; i++) { %>
44
- import * as mod_<%= i %>
45
- from '<%= mods[i] %>';
46
- appDefaultOptions = notCommon.absorbModule({
47
- defaultConf: appDefaultOptions,
48
- mod: mod_<%= i %>,
49
- services, uis, wsc, fields
50
- });
51
- <% } %>
52
-
53
- COMPONENTS.import(uis);
54
-
55
- import 'bulma';
56
-
57
- <% for(var i = 0; i < scss.length; i++) { %>
58
- import '<%= scss[i] %>';
59
- <% } %>
60
-
61
- appDefaultOptions.services = services;
62
- appDefaultOptions.wsc = wsc;
63
-
64
- notCommon.startApp(() => new notApp(appDefaultOptions));
@@ -1,70 +0,0 @@
1
- // Rollup plugins
2
- import babel from "@rollup/plugin-babel";
3
- import commonjs from "@rollup/plugin-commonjs";
4
- import svelte from "rollup-plugin-svelte";
5
- import resolve from "@rollup/plugin-node-resolve";
6
- import filesize from "rollup-plugin-filesize";
7
- import sizes from "rollup-plugin-sizes";
8
- import postcss from "rollup-plugin-postcss";
9
- import json from "@rollup/plugin-json";
10
-
11
- import { babelOn } from "./build.env.js";
12
-
13
- export default {
14
- input: "<%= inputPath %>",
15
- output: {
16
- file: "<%= outputPath %>",
17
- name: "<%= appName %>",
18
- format: "iife",
19
- sourcemap:
20
- false && (process.env.NODE_ENV === "production" ? false : "inline"),
21
- },
22
- plugins: [
23
- json(),
24
- svelte({
25
- emitCss: true,
26
- }),
27
- resolve({
28
- browser: true,
29
- preferBuiltins: true,
30
- dedupe: (importee) =>
31
- importee === "svelte" || importee.startsWith("svelte/"),
32
- }),
33
- commonjs({}),
34
- postcss({
35
- extract: true,
36
- minimize: true,
37
- use: [
38
- [
39
- "sass",
40
- {
41
- includePaths: ["./src/styles/theme", "./node_modules"],
42
- },
43
- ],
44
- ],
45
- }),
46
- babelOn() &&
47
- babel({
48
- presets: [
49
- [
50
- "@babel/preset-env",
51
- {
52
- corejs: 3,
53
- modules: false,
54
- useBuiltIns: "usage",
55
- targets: "> 2.5%, not dead",
56
- },
57
- ],
58
- ],
59
- babelHelpers: "bundled",
60
- plugins: [
61
- "@babel/plugin-proposal-class-properties",
62
- "@babel/plugin-proposal-private-methods",
63
- "@babel/transform-arrow-functions",
64
- ],
65
- exclude: ["node_modules/**", "build/**"],
66
- }),
67
- sizes(),
68
- filesize(),
69
- ],
70
- };
@@ -1,45 +0,0 @@
1
- import ncInit from "../../common/ncInit";
2
-
3
- let manifest = {
4
- environment: "guest",
5
- router: {
6
- manifest: [],
7
- },
8
- crud: {
9
- containerSelector: ".main-container",
10
- },
11
- modules: {
12
- user: {
13
- loginFormContainerSelector: ".main-container",
14
- registerFormContainerSelector: ".main-container",
15
- },
16
- },
17
- initController: ncInit,
18
- menu: {
19
- top: {
20
- toggleSelector: ".navbar-burger",
21
- sections: [],
22
- items: [
23
- {
24
- title: "Вход",
25
- url: "/login",
26
- priority: 10,
27
- showOnTouch: true,
28
- type: "button",
29
- place: "start",
30
- } , {
31
- id: 'register',
32
- title: 'Регистрация',
33
- url: '/register',
34
- type: 'button',
35
- priority: 11,
36
- showOnTouch:true,
37
- place: 'start'
38
- },
39
- ],
40
- },
41
- },
42
- };
43
-
44
-
45
- export { ncInit, manifest };
@@ -1,45 +0,0 @@
1
- import ncInit from "../../common/ncInit";
2
-
3
- let manifest = {
4
- environment: "guest",
5
- router: {
6
- manifest: [],
7
- },
8
- crud: {
9
- containerSelector: ".main-container",
10
- },
11
- modules: {
12
- user: {
13
- loginFormContainerSelector: ".main-container",
14
- registerFormContainerSelector: ".main-container",
15
- },
16
- },
17
- initController: ncInit,
18
- menu: {
19
- top: {
20
- toggleSelector: ".navbar-burger",
21
- sections: [],
22
- items: [
23
- {
24
- title: "Вход",
25
- url: "/login",
26
- priority: 10,
27
- showOnTouch: true,
28
- type: "button",
29
- place: "start",
30
- } , {
31
- id: 'register',
32
- title: 'Регистрация',
33
- url: '/register',
34
- type: 'button',
35
- priority: 11,
36
- showOnTouch:true,
37
- place: 'start'
38
- },
39
- ],
40
- },
41
- },
42
- };
43
-
44
-
45
- export { ncInit, manifest };
@@ -1,39 +0,0 @@
1
-
2
- import main from './ws.client.main.js';
3
-
4
-
5
- let manifest = {
6
- brand: {
7
- icon: {
8
- src: '/img/icons/icon-w-64.png',
9
- width: 48,
10
- height: 28
11
- },
12
- title: 'notNodeApplication',
13
- url: '/'
14
- },
15
- modules:{
16
-
17
- ws:{
18
- clients:{
19
- //options for ws client here
20
- main: {
21
- host: window.location.hostname,
22
- path: 'websocket',
23
- secure: true,
24
- ssl: true
25
- }
26
- }
27
- }
28
-
29
- }
30
- };
31
-
32
- const wsc = {
33
- main
34
- };
35
-
36
- export {
37
- manifest,
38
- wsc
39
- };
@@ -1,18 +0,0 @@
1
- import { Frame } from 'not-bulma';
2
-
3
- const {
4
- notSideMenu, notTopMenu,
5
- notController} = Frame;
6
-
7
- class ncInit extends notController {
8
- constructor(app) {
9
- super(app);
10
- this.setModuleName('init');
11
- this.log('init app');
12
- notSideMenu.render(app);
13
- notTopMenu.render(app);
14
- return this;
15
- }
16
- }
17
-
18
- export default ncInit;