@robgietema/generator-nick 0.0.1

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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Rob Gietema
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Yeoman Nick App Generator
2
+
3
+ @robgietema/generator-nick is a Yeoman generator that helps you to set up Nick via command line.
4
+
5
+ ## Installation
6
+
7
+ First, install [Yeoman](http://yeoman.io) and @robgietema/generator-nick using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
8
+
9
+ ```bash
10
+ npm install -g yo
11
+ npm install -g @robgietema/generator-nick
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Creating a new Nick project using `npm init`
17
+
18
+ ```bash
19
+ npm init yo @robgietema/nick
20
+ ```
21
+
22
+ This is the shortcut for using `npm init` command. It uses Yeoman (`yo`) and `@robgietema/generator-nick` and execute them without having to be installed globally.
23
+
24
+ Answer the prompt questions to complete the generation process.
25
+
26
+ ### Creating a new Nick project
27
+
28
+ ```bash
29
+ yo @robgietema/nick
30
+ ```
31
+
32
+ This will bootstrap a new Nick project inside the current folder.
33
+
34
+ ### Start Nick with `yarn start`
35
+
36
+ Start Nick with:
37
+
38
+ ```bash
39
+ yarn start
40
+ ```
41
+
42
+ This runs the project in development mode.
43
+
44
+ Consult the Nick docs for further details:
45
+
46
+ https://nickcms.org
47
+
48
+ ### Run unit tests with `yarn test`
49
+
50
+ Runs all the tests.
51
+
52
+ ### Update translations with `yarn i18n`
53
+
54
+ Runs the test i18n runner which extracts all the translation strings and generates the needed files.
@@ -0,0 +1,148 @@
1
+ const path = require('path');
2
+ const Generator = require('yeoman-generator');
3
+
4
+ const currentDir = path.basename(process.cwd());
5
+
6
+ module.exports = class extends Generator {
7
+ constructor(args, opts) {
8
+ super(args, opts);
9
+ this.argument('projectName', {
10
+ type: String,
11
+ default: currentDir,
12
+ });
13
+ this.option('description', {
14
+ type: String,
15
+ desc: 'Project description',
16
+ });
17
+
18
+ this.args = args;
19
+ this.opts = opts;
20
+ }
21
+
22
+ async prompting() {
23
+ const updateNotifier = require('update-notifier');
24
+ const pkg = require('../../package.json');
25
+ const notifier = updateNotifier({
26
+ pkg,
27
+ shouldNotifyInNpmScript: true,
28
+ updateCheckInterval: 0,
29
+ });
30
+ notifier.notify({
31
+ defer: false,
32
+ message: `Update available: {currentVersion} -> {latestVersion}
33
+
34
+ It's important to have the generators updated!
35
+
36
+ Run "npm install -g @robgietema/generator-nick" to update.`,
37
+ });
38
+
39
+ let props;
40
+
41
+ this.globals = {};
42
+
43
+ // Project name
44
+ if (this.args[0]) {
45
+ this.globals.projectName = this.args[0];
46
+ } else {
47
+ if (this.opts['interactive']) {
48
+ props = await this.prompt([
49
+ {
50
+ type: 'input',
51
+ name: 'projectName',
52
+ message: 'Project name (e.g. my-nick-project)',
53
+ default: path.basename(process.cwd()),
54
+ },
55
+ ]);
56
+ this.globals.projectName = props.projectName;
57
+ } else {
58
+ this.globals.projectName = path.basename(process.cwd());
59
+ }
60
+ }
61
+
62
+ // Description
63
+ if (this.opts.description) {
64
+ this.globals.projectDescription = this.opts.description;
65
+ } else {
66
+ this.globals.projectDescription = 'A Nick-powered Backend';
67
+ }
68
+ }
69
+
70
+ writing() {
71
+ const base =
72
+ currentDir === this.globals.projectName ? '.' : this.globals.projectName;
73
+ this.fs.copyTpl(
74
+ this.templatePath('package.json.tpl'),
75
+ this.destinationPath(base, 'package.json'),
76
+ this.globals,
77
+ );
78
+ this.fs.copyTpl(
79
+ this.templatePath('config.js.tpl'),
80
+ this.destinationPath(base, 'config.js'),
81
+ this.globals,
82
+ );
83
+
84
+ this.fs.copy(this.templatePath(), this.destinationPath(base), {
85
+ globOptions: {
86
+ ignore: ['**/*.tpl', '**/*~'],
87
+ dot: true,
88
+ },
89
+ });
90
+
91
+ this.fs.copyTpl(
92
+ this.templatePath('.gitignorefile'),
93
+ this.destinationPath(base, '.gitignore'),
94
+ this.globals,
95
+ );
96
+
97
+ this.fs.delete(this.destinationPath(base, 'config.js.tpl'));
98
+ this.fs.delete(this.destinationPath(base, 'package.json.tpl'));
99
+ this.fs.delete(this.destinationPath(base, '.gitignorefile'));
100
+ }
101
+
102
+ install() {
103
+ if (!this.opts['skip-install']) {
104
+ const base =
105
+ currentDir === this.globals.projectName
106
+ ? '.'
107
+ : this.globals.projectName;
108
+ this.yarnInstall(null, { cwd: base });
109
+ }
110
+ }
111
+
112
+ end() {
113
+ if (!this.opts['skip-install']) {
114
+ this.log(
115
+ `
116
+ Done.
117
+
118
+ Now install and run Postgres and setup the database by entering the following in your Postgres console:
119
+
120
+ $ CREATE DATABASE ${this.globals.projectName};
121
+ $ CREATE USER nick WITH ENCRYPTED PASSWORD '${this.globals.projectName}';
122
+ $ GRANT ALL PRIVILEGES ON DATABASE ${this.globals.projectName} TO ${this.globals.projectName};
123
+
124
+ Now go to the ${this.globals.projectName} folder and run:
125
+
126
+ yarn bootstrap
127
+ yarn start
128
+ `,
129
+ );
130
+ } else {
131
+ this.log(`
132
+ Done.
133
+
134
+ Now install and run Postgres and setup the database by entering the following in your Postgres console:
135
+
136
+ $ CREATE DATABASE ${this.globals.projectName};
137
+ $ CREATE USER nick WITH ENCRYPTED PASSWORD '${this.globals.projectName}';
138
+ $ GRANT ALL PRIVILEGES ON DATABASE ${this.globals.projectName} TO ${this.globals.projectName};
139
+
140
+ Now go to the ${this.globals.projectName} folder and run:
141
+
142
+ yarn install
143
+ yarn bootstrap
144
+ yarn start
145
+ `);
146
+ }
147
+ }
148
+ };
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ src/develop/
@@ -0,0 +1,9 @@
1
+ {
2
+ "parserOptions": {
3
+ "parser": "@babel/eslint-parser",
4
+ "ecmaVersion": 2022,
5
+ "sourceType": "module"
6
+ },
7
+ "extends": ["prettier"],
8
+ "plugins": ["json", "prettier"]
9
+ }
@@ -0,0 +1,6 @@
1
+
2
+ .DS_Store
3
+ node_modules/
4
+ /src/develop
5
+ /config.js
6
+ /var
@@ -0,0 +1 @@
1
+ /src/develop
@@ -0,0 +1,8 @@
1
+ {
2
+ "presets": ["@babel/preset-env"],
3
+ "plugins": [
4
+ "@babel/transform-runtime",
5
+ "@babel/plugin-proposal-export-default-from",
6
+ "add-module-exports"
7
+ ]
8
+ }
@@ -0,0 +1,39 @@
1
+ export const config = {
2
+ connection: {
3
+ port: 5432,
4
+ host: 'localhost',
5
+ database: '<%= projectName %>',
6
+ user: '<%= projectName %>',
7
+ password: '<%= projectName %>',
8
+ },
9
+ blobsDir: `${__dirname}/var/blobstorage`,
10
+ port: 8000,
11
+ secret: 'secret',
12
+ clientMaxSize: '64mb',
13
+ systemUsers: ['admin', 'anonymous'],
14
+ systemGroups: ['Owner'],
15
+ cors: {
16
+ allowOrigin: '*',
17
+ allowMethods: '*',
18
+ allowHeaders: '*',
19
+ allowCredentials: true,
20
+ exposeHeaders: '*',
21
+ maxAge: 3660,
22
+ },
23
+ imageScales: {
24
+ large: [768, 768],
25
+ preview: [400, 400],
26
+ mini: [200, 200],
27
+ thumb: [128, 128],
28
+ tile: [64, 64],
29
+ icon: [32, 32],
30
+ listing: [16, 16],
31
+ },
32
+ frontendUrl: 'http://localhost:3000',
33
+ prefix: '',
34
+ userRegistration: true,
35
+ profiles: [
36
+ `${__dirname}/src/develop/nick/src/profiles/core`,
37
+ `${__dirname}/src/profiles/default`,
38
+ ],
39
+ };
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@robgietema/nick": [
5
+ "develop/nick/src"
6
+ ]
7
+ },
8
+ "baseUrl": "src"
9
+ }
10
+ }
@@ -0,0 +1,26 @@
1
+ var path = require('path');
2
+ var { config } = require('./config');
3
+
4
+ const knexSettings = {
5
+ client: 'pg',
6
+ connection: config.connection,
7
+ pool: {
8
+ min: 2,
9
+ max: 10,
10
+ },
11
+ migrations: {
12
+ directory: [
13
+ path.resolve(__dirname, './src/develop/nick/src/migrations'),
14
+ path.resolve(__dirname, './src/migrations'),
15
+ ],
16
+ tableName: 'knex_migrations',
17
+ },
18
+ seeds: {
19
+ directory: path.resolve(__dirname, './src/develop/nick/src/seeds'),
20
+ },
21
+ };
22
+
23
+ module.exports = {
24
+ development: knexSettings,
25
+ production: knexSettings,
26
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "nick": {
3
+ "package": "@robgietema/nick",
4
+ "url": "git@github.com:robgietema/nick.git",
5
+ "https": "https://github.com/robgietema/nick.git",
6
+ "path": "src",
7
+ "branch": "main"
8
+ }
9
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "<%= projectName %>",
3
+ "description": "",
4
+ "license": "MIT",
5
+ "version": "0.0.1",
6
+ "private": true,
7
+ "workspaces": [
8
+ "src/develop/nick"
9
+ ],
10
+ "keywords": [
11
+ "cms"
12
+ ],
13
+ "scripts": {
14
+ "develop": "missdev --config=jsconfig.json --fetch-https",
15
+ "develop:npx": "npx -p mrs-developer missdev --config=jsconfig.json --fetch-https",
16
+ "bootstrap": "yarn && yarn migrate && yarn seed",
17
+ "coverage": "jest --coverage",
18
+ "i18n": "babel-node scripts/i18n.js",
19
+ "i18n:ci": "yarn i18n && git diff -G'^[^\"POT]' --exit-code",
20
+ "knex": "babel-node --plugins ./src/develop/nick/src/plugins/strip-i18n.js node_modules/.bin/knex",
21
+ "lint": "./node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx,json}' --no-error-on-unmatched-pattern",
22
+ "migrate": "yarn knex migrate:latest",
23
+ "preinstall": "if [ -f $(pwd)/node_modules/.bin/missdev ]; then yarn develop; else yarn develop:npx; fi",
24
+ "prettier": "./node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,ts,tsx,json}'",
25
+ "seed": "yarn knex seed:run",
26
+ "start": "nodemon --exec babel-node src/develop/nick/src/server.js",
27
+ "rollback": "yarn knex migrate:rollback --all",
28
+ "reset": "yarn rollback && yarn migrate && yarn seed",
29
+ "test": "jest --passWithNoTests"
30
+ },
31
+ "prettier": {
32
+ "trailingComma": "all",
33
+ "singleQuote": true
34
+ },
35
+ "jest": {
36
+ "testPathIgnorePatterns": [
37
+ "/node_modules/",
38
+ "/src/develop"
39
+ ],
40
+ "setupFilesAfterEnv": [
41
+ "./src/develop/nick/jest.setup.js"
42
+ ]
43
+ },
44
+ "engines": {
45
+ "node": "^16.15.0"
46
+ },
47
+ "devDependencies": {},
48
+ "dependencies": {}
49
+ }
File without changes
@@ -0,0 +1,155 @@
1
+ {
2
+ "uuid": "92a80817-f5b7-400d-8f58-b08126f0f09b",
3
+ "type": "Site",
4
+ "title": "Welcome to Nick!",
5
+ "description": "Congratulations! You have successfully installed Nick.",
6
+ "owner": "admin",
7
+ "workflow_state": "published",
8
+ "created": "2022-04-02T20:00:00.000Z",
9
+ "modified": "2022-04-02T20:00:00.000Z",
10
+ "effective": "2022-04-02T20:00:00.000Z",
11
+
12
+ "blocks": {
13
+ "495efb73-cbdd-4bef-935a-a56f70a20854": {
14
+ "text": {
15
+ "blocks": [
16
+ {
17
+ "key": "9f35d",
18
+ "data": {},
19
+ "text": "This is the demo site of Nick and is build with the Volto frontend.",
20
+ "type": "unstyled",
21
+ "depth": 0,
22
+ "entityRanges": [
23
+ {
24
+ "key": 0,
25
+ "length": 4,
26
+ "offset": 25
27
+ },
28
+ {
29
+ "key": 1,
30
+ "length": 5,
31
+ "offset": 52
32
+ }
33
+ ],
34
+ "inlineStyleRanges": []
35
+ }
36
+ ],
37
+ "entityMap": {
38
+ "0": {
39
+ "data": {
40
+ "url": "https://nickcms.org"
41
+ },
42
+ "type": "LINK",
43
+ "mutability": "MUTABLE"
44
+ },
45
+ "1": {
46
+ "data": {
47
+ "url": "https://voltocms.com"
48
+ },
49
+ "type": "LINK",
50
+ "mutability": "MUTABLE"
51
+ }
52
+ }
53
+ },
54
+ "@type": "text"
55
+ },
56
+ "6a6d1e67-fefd-4049-98a3-300f0302abcb": {
57
+ "text": {
58
+ "blocks": [
59
+ {
60
+ "key": "3jol2",
61
+ "data": {},
62
+ "text": "You can use this site to test the latest version of Nick. You can login with username admin and password admin.",
63
+ "type": "unstyled",
64
+ "depth": 0,
65
+ "entityRanges": [
66
+ {
67
+ "key": 0,
68
+ "length": 4,
69
+ "offset": 52
70
+ }
71
+ ],
72
+ "inlineStyleRanges": [
73
+ {
74
+ "style": "ITALIC",
75
+ "length": 8,
76
+ "offset": 77
77
+ },
78
+ {
79
+ "style": "ITALIC",
80
+ "length": 8,
81
+ "offset": 96
82
+ },
83
+ {
84
+ "style": "BOLD",
85
+ "length": 5,
86
+ "offset": 86
87
+ },
88
+ {
89
+ "style": "BOLD",
90
+ "length": 5,
91
+ "offset": 105
92
+ }
93
+ ]
94
+ }
95
+ ],
96
+ "entityMap": {
97
+ "0": {
98
+ "data": {
99
+ "url": "https://nickcms.org"
100
+ },
101
+ "type": "LINK",
102
+ "mutability": "MUTABLE"
103
+ }
104
+ }
105
+ },
106
+ "@type": "text"
107
+ },
108
+ "79ba8858-1dd3-4719-b731-5951e32fbf79": {
109
+ "@type": "title"
110
+ },
111
+ "be383a3d-7409-42b5-a5bc-555e2fbf068d": {
112
+ "text": {
113
+ "blocks": [
114
+ {
115
+ "key": "atc31",
116
+ "data": {},
117
+ "text": "This instance is reset every night so feel free to make any changes!",
118
+ "type": "unstyled",
119
+ "depth": 0,
120
+ "entityRanges": [],
121
+ "inlineStyleRanges": []
122
+ }
123
+ ],
124
+ "entityMap": {}
125
+ },
126
+ "@type": "text"
127
+ },
128
+ "eb024f35-ab6a-4034-ac5b-77c91fe3d400": {
129
+ "text": {
130
+ "blocks": [
131
+ {
132
+ "key": "5s8ah",
133
+ "data": {},
134
+ "text": "Demo",
135
+ "type": "header-three",
136
+ "depth": 0,
137
+ "entityRanges": [],
138
+ "inlineStyleRanges": []
139
+ }
140
+ ],
141
+ "entityMap": {}
142
+ },
143
+ "@type": "text"
144
+ }
145
+ },
146
+ "blocks_layout": {
147
+ "items": [
148
+ "79ba8858-1dd3-4719-b731-5951e32fbf79",
149
+ "495efb73-cbdd-4bef-935a-a56f70a20854",
150
+ "eb024f35-ab6a-4034-ac5b-77c91fe3d400",
151
+ "6a6d1e67-fefd-4049-98a3-300f0302abcb",
152
+ "be383a3d-7409-42b5-a5bc-555e2fbf068d"
153
+ ]
154
+ }
155
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "purge": true,
3
+ "groups": [
4
+ {
5
+ "id": "Administrators",
6
+ "title:i18n": "Administrators",
7
+ "description:i18n": "",
8
+ "email": "",
9
+ "roles": ["Administrator"]
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "purge": false,
3
+ "users": [
4
+ {
5
+ "id": "admin",
6
+ "password": "admin",
7
+ "fullname": "Admin",
8
+ "email": "admin@example.com",
9
+ "roles": ["Administrator"]
10
+ }
11
+ ]
12
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@robgietema/generator-nick",
3
+ "description": "Generator for Nick",
4
+ "maintainers": [
5
+ {
6
+ "name": "Rob Gietema",
7
+ "email": "rob.gietema@gmail.com",
8
+ "url": "https://robgietema.nl"
9
+ }
10
+ ],
11
+ "license": "MIT",
12
+ "version": "0.0.1",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git@github.com:robgietema/nick.git"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/robgietema/nick/issues",
22
+ "email": "info@nickcms.org"
23
+ },
24
+ "homepage": "https://nickcms.org",
25
+ "files": [
26
+ "generators"
27
+ ],
28
+ "keywords": [
29
+ "yeoman-generator",
30
+ "cms"
31
+ ],
32
+ "engines": {
33
+ "node": "^16.15.0"
34
+ },
35
+ "dependencies": {
36
+ "update-notifier": "^5.0.1",
37
+ "yeoman-generator": "^1.0.0"
38
+ }
39
+ }