create-juisy 2.0.0-beta.10 → 2.0.0-beta.11

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 (39) hide show
  1. package/index.js +21 -9
  2. package/package.json +3 -3
  3. package/template/.env.example +1 -1
  4. package/template/COMMIT_CONVENTION.md +116 -0
  5. package/template/CONTRIBUTING.md +21 -0
  6. package/template/bin/cli/cli.js +11 -14
  7. package/template/bin/cli/cmds/index.js +0 -2
  8. package/template/bin/cli/cmds/private/docs/index.js +1 -0
  9. package/template/bin/cli/index.js +4 -2
  10. package/template/bin/scripts/commit-msg.js +13 -18
  11. package/template/bin/scripts/pre-commit.js +13 -11
  12. package/template/dev.config.js +20 -8
  13. package/template/dev.config.json +19 -1
  14. package/template/dev.config.ts +20 -1
  15. package/template/docs/.markdownlint-cli2.mjs +21 -0
  16. package/template/docs/cli/private/config.js +37 -0
  17. package/template/docs/cli/private/data.js +14 -0
  18. package/template/docs/cli/private/partials/child-command.md +26 -0
  19. package/template/docs/cli/private/template.md +26 -0
  20. package/template/docs/cli/public/config.js +21 -0
  21. package/template/docs/cli/public/template.md +19 -0
  22. package/template/docs/readme/config.js +24 -13
  23. package/template/docs/readme/data.js +45 -0
  24. package/template/docs/readme/template.md +10 -6
  25. package/template/eslint.config.js +47 -0
  26. package/template/package.json +2 -4
  27. package/template/project.globals.js +20 -29
  28. package/template/bin/cli/cmds/private/changelog.js +0 -44
  29. package/template/bin/cli/cmds/private/docs/generate-cli.js +0 -11
  30. package/template/bin/cli/cmds/private/docs/generate-readme.js +0 -11
  31. package/template/bin/cli/cmds/private/docs/lint.js +0 -42
  32. package/template/bin/cli/cmds/private/git-hooks/index.js +0 -20
  33. package/template/bin/cli/cmds/private/git-hooks/reset.js +0 -48
  34. package/template/bin/cli/cmds/private/git-hooks/sync.js +0 -19
  35. package/template/bin/cli/cmds/private/release.js +0 -223
  36. package/template/bin/cli/lib/docs/generate-api-doc.js +0 -33
  37. package/template/bin/cli/lib/release/generate-release-note.js +0 -3
  38. package/template/bin/cli/lib/version/update-version.js +0 -51
  39. package/template/docs/readme/readme.js +0 -70
@@ -0,0 +1,19 @@
1
+ # CLI
2
+
3
+ ## Usage
4
+
5
+ ```console
6
+ <%%- $filters.stripAnsi(rootDoclet.rawUsage) %>
7
+ ```
8
+
9
+ ## Commands
10
+
11
+ <%% for (const child in rootDoclet.children) { %>
12
+ <%%-
13
+ await include('child-command.md', {
14
+ cmdDoclet: rootDoclet.children[child],
15
+ hLevel: 3,
16
+ recursive: true
17
+ })
18
+ %>
19
+ <%% } %>
@@ -1,22 +1,33 @@
1
1
  /**
2
- * @hperchec/readme-generator Example configuration file
2
+ * ReadmeTemplater configuration file
3
3
  */
4
4
 
5
- const path = require('path')
5
+ import path, { dirname } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
6
7
 
7
- // Export configuration
8
- module.exports = {
9
- // Template path
10
- templatePath: path.resolve(__dirname, './template.md'), // Default template file
11
- // Output path
12
- outputPath: path.resolve(__dirname, '../../'), // Your project root directory by default
13
- // Output file name
14
- outputName: 'README.md', // 'README.md' by default
15
- // Path to ejs data file
16
- ejsDataPath: path.resolve(__dirname, './readme.js'), // Default template ejs data file
8
+ const __filename = fileURLToPath(import.meta.url)
9
+ const __dirname = dirname(__filename)
10
+
11
+ /** @type {import('juisy/templater').ReadmeTemplaterUserConfig} */
12
+ export default {
13
+ /**
14
+ * Output file name: 'README.md' by default
15
+ */
16
+ fileName: 'README.md',
17
+ /**
18
+ * Change destination folder
19
+ */
20
+ destFolder: path.resolve(__dirname, '../..'),
21
+ /**
22
+ * Template entry file path
23
+ */
24
+ templatePath: path.resolve(__dirname, './template.md'),
25
+ /**
26
+ * EJS data file
27
+ */
28
+ ejsDataPath: path.resolve(__dirname, './data.js'),
17
29
  // EJS options (see https://www.npmjs.com/package/ejs#options)
18
30
  ejsOptions: {
19
- async: true
20
31
  /* your ejs options... */
21
32
  }
22
33
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * ReadmeTemplater EJS data file
3
+ */
4
+
5
+ import { getPackageInfo } from 'juisy'
6
+
7
+ // Based on the package.json file, get some data and informations
8
+ const pkg = getPackageInfo()
9
+
10
+ /**
11
+ * Return author link
12
+ * @param {Object} author
13
+ * @return {string}
14
+ */
15
+ function getMdAuthor (author) {
16
+ return '[' + author.name + '](' + author.url + ')'
17
+ }
18
+
19
+ /**
20
+ * Return markdown list of persons
21
+ * @param {Array} contributors
22
+ * @return {String}
23
+ */
24
+ function getMdContributors (contributors) {
25
+ let mdString = ''
26
+ contributors.forEach((person) => {
27
+ mdString += '- [' + person.name + '](' + person.url + ')\n'
28
+ })
29
+ return mdString
30
+ }
31
+
32
+ /**
33
+ * Export data for readme file templating
34
+ */
35
+ export const packageName = pkg.name
36
+ export const packageUrl = `https://www.npmjs.com/package/${packageName}`
37
+ export const dependencies = pkg.dependencies || {}
38
+ export const devDependencies = pkg.devDependencies || {}
39
+ export const peerDependencies = pkg.peerDependencies || {}
40
+ export const projectUrl = pkg.repository.url.match(/^git\+(.*)\.git$/)[1] // find string between 'git+' and '.git'
41
+ export const projectPath = projectUrl.replace('https://gitlab.com/', '') // remove domain name
42
+ export const issuesUrl = pkg.bugs.url
43
+ export const license = pkg.license || 'Unknown'
44
+ export const author = getMdAuthor(pkg.author)
45
+ export const contributors = getMdContributors(pkg.contributors || [])
@@ -1,11 +1,16 @@
1
1
  # Awesome project
2
2
 
3
- [![author](https://img.shields.io/static/v1?label=&message=Author:&color=black)]()
3
+ [![author](https://img.shields.io/static/v1?label=&message=Author:&color=black)](http://herve-perchec.com/)
4
4
  [![herve-perchec](http://herve-perchec.com/badge.svg)](http://herve-perchec.com/)
5
5
 
6
- **Table of contents**:
6
+ > You can use [shields.io](https://shields.io/) to generate your own badges!
7
7
 
8
- [[*TOC*]]
8
+ ## Table of contents
9
+
10
+ <%#
11
+ // Table of contents is automatically injected here by
12
+ // [remark-toc](https://github.com/remarkjs/remark-toc)
13
+ -%>
9
14
 
10
15
  ## 🚀 Get started
11
16
 
@@ -13,9 +18,8 @@
13
18
  # Let's go!
14
19
  ```
15
20
 
16
- ## 📙 Documentation
17
-
18
- Please check the [documentation](https://www.npmjs.com/package/@hperchec/juisy)
21
+ This project is made with [Juisy](https://www.npmjs.com/package/juisy).
22
+ Read the [documentation](https://hperchec.gitlab.io/juisy) to learn more!
19
23
 
20
24
  ## 🧱 Dependencies
21
25
 
@@ -0,0 +1,47 @@
1
+ import globals from 'globals'
2
+ import js from '@eslint/js'
3
+ import stylistic from '@stylistic/eslint-plugin'
4
+
5
+ /** @type {import('eslint').Linter.Config[]} */
6
+ export default [
7
+ {
8
+ languageOptions: {
9
+ globals: {
10
+ ...globals.node
11
+ }
12
+ }
13
+ },
14
+ /**
15
+ * See: https://eslint.style/packages/default
16
+ */
17
+ stylistic.configs.customize({
18
+ // ...
19
+ }),
20
+ /**
21
+ * Our rules configuration
22
+ */
23
+ {
24
+ rules: {
25
+ // @eslint/js
26
+ ...js.configs.recommended.rules,
27
+ 'no-unused-vars': [ 'error', {
28
+ args: 'none'
29
+ } ],
30
+ // @stylistic/eslint-plugin
31
+ '@stylistic/array-bracket-spacing': [ 'error', 'always' ],
32
+ '@stylistic/brace-style': [ 'error', '1tbs' ],
33
+ '@stylistic/comma-dangle': [ 'error', 'never' ],
34
+ '@stylistic/space-before-function-paren': [ 'error', 'always' ]
35
+ }
36
+ },
37
+ {
38
+ files: [
39
+ '**/bin/cli/**/*.js'
40
+ ],
41
+ languageOptions: {
42
+ globals: {
43
+ CLI: 'readonly'
44
+ }
45
+ }
46
+ }
47
+ ]
@@ -1,11 +1,9 @@
1
1
  {
2
- "name": "new-project",
2
+ "name": "__PROJECT_NAME__",
3
3
  "version": "1.0.0",
4
4
  "description": "New project based on Juisy template",
5
5
  "type": "module",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
6
+ "scripts": {},
9
7
  "repository": {
10
8
  "type": "git",
11
9
  "url": "git+https://gitlab.com/hperchec/juisy.git"
@@ -1,33 +1,24 @@
1
- import pkg from './package.json' assert { type: 'json' }
1
+ import { defineGlobals } from 'juisy'
2
2
 
3
- // Exports globals object
4
- export default {
5
- ENV: {
6
- NODE_ENV: process.env.NODE_ENV
3
+ export default defineGlobals(
4
+ {
5
+ // The environment variables to auto includes in "ENV" property
6
+ env: { map: [ 'NODE_ENV' ] }
7
7
  },
8
- PACKAGE: {
9
- NAME: pkg.name,
10
- URL: `https://www.npmjs.com/package/${pkg.name}`
11
- },
12
- VERSION: pkg.version,
13
- AUTHOR: {
14
- EMAIL: pkg.author.email,
15
- NAME: pkg.author.name,
16
- URL: pkg.author.url
17
- },
18
- REPOSITORY: {
19
- TYPE: pkg.repository.type,
20
- URL: pkg.repository.url
21
- },
22
- ISSUES_URL: pkg.bugs.url,
23
- HOMEPAGE: pkg.homepage,
24
- BRAND: {
25
- COLORS: {
26
- GERALDINE: '#FF8E92',
27
- SAND: '#FFC17A',
28
- COGNAC: '#A04113',
29
- DARK_PINK: '#E95185',
30
- PINK_SHERBET: '#F583A3'
8
+ // Access to all environment variables and package.json info
9
+ ({ env, pkg }) => {
10
+ return {
11
+ // Define your brand specific constants
12
+ BRAND: {
13
+ NAME: 'My brand',
14
+ COLORS: {
15
+ GERALDINE: '#FF8E92',
16
+ SAND: '#FFC17A',
17
+ COGNAC: '#A04113',
18
+ DARK_PINK: '#E95185',
19
+ PINK_SHERBET: '#F583A3'
20
+ }
21
+ }
31
22
  }
32
23
  }
33
- }
24
+ )
@@ -1,44 +0,0 @@
1
- /** @type {import('juisy/cli').Command} */
2
- export default new CLI.Command({
3
- command: 'changelog',
4
- describe: 'Generate CHANGELOG file',
5
- meta: {
6
- private: true
7
- },
8
- builder: function (cli) {
9
- return cli.option('i', {
10
- alias: 'infile',
11
- type: 'string',
12
- describe: 'Same as conventional-changelog option',
13
- default: 'CHANGELOG.md',
14
- requiresArg: true
15
- })
16
- },
17
- async handler (argv) {
18
- // Utils
19
- const { $style, step, substep, error } = CLI.OutputUtils
20
- const { run, wait } = CLI.InterfaceUtils
21
- /**
22
- * Generate changelog file
23
- */
24
- step('Generating changelog')
25
- await wait('Generating', async () => {
26
- try {
27
- await run(
28
- 'npx',
29
- [
30
- 'conventional-changelog',
31
- '-p', 'angular',
32
- '-i', argv.infile,
33
- '-s' // same file to output
34
- ],
35
- { stdio: 'pipe' }
36
- )
37
- } catch (e) {
38
- error('Unable to generate changelog', e)
39
- }
40
- })
41
- substep($style.green('✔ Success'), { last: true })
42
- this.log() // Blank line
43
- }
44
- })
@@ -1,11 +0,0 @@
1
- import { ReadmeTemplater } from 'juisy/templater'
2
-
3
- /** @type {import('juisy/cli').Command} */
4
- export default new CLI.Command({
5
- command: 'generate:cli',
6
- describe: 'Generate CLI docs',
7
- async handler (argv) {
8
- const templater = new ReadmeTemplater('./docs/cli/config.js')
9
- await templater.generate()
10
- }
11
- })
@@ -1,11 +0,0 @@
1
- import { ReadmeTemplater } from 'juisy/templater'
2
-
3
- /** @type {import('juisy/cli').Command} */
4
- export default new CLI.Command({
5
- command: 'generate:readme',
6
- describe: 'Generate README.md',
7
- async handler (argv) {
8
- const templater = new ReadmeTemplater('./docs/readme/config.js')
9
- await templater.generate()
10
- }
11
- })
@@ -1,42 +0,0 @@
1
- /** @type {import('juisy/cli').Command} */
2
- export default new CLI.Command({
3
- command: 'lint',
4
- describe: 'Lint markdown with markdownlint',
5
- builder: function (cli) {
6
- cli.option('c', {
7
- alias: 'config',
8
- type: 'string',
9
- describe: 'Path to custom markdownlint config file (relative to root folder)',
10
- requiresArg: true
11
- })
12
- cli.option('f', {
13
- alias: 'fix',
14
- type: 'boolean',
15
- describe: 'Auto fix by passing --fix option to markdownlint-cli2',
16
- default: false
17
- })
18
- return cli
19
- },
20
- async handler (argv) {
21
- const { abort, run } = CLI.InterfaceUtils
22
- const configPath = argv.config || './docs/.markdownlint-cli2.cjs' // default relative to root folder
23
-
24
- /**
25
- * Call markdownlint command
26
- */
27
- try {
28
- await run(
29
- 'npx',
30
- [
31
- 'markdownlint-cli2',
32
- '--config',
33
- configPath,
34
- ...(argv.fix ? [ '--fix' ] : [])
35
- ],
36
- { stdio: 'inherit' }
37
- )
38
- } catch (error) {
39
- abort(error.exitCode)
40
- }
41
- }
42
- })
@@ -1,20 +0,0 @@
1
- import reset from './reset.js'
2
- import sync from './sync.js'
3
-
4
- /** @type {import('juisy/cli').Command} */
5
- export default new CLI.Command({
6
- command: 'git-hooks <command>',
7
- describe: 'Git relative commands',
8
- meta: {
9
- private: true
10
- },
11
- builder: function (cli) {
12
- return cli
13
- .command([
14
- reset,
15
- sync
16
- ])
17
- .demandCommand(1, 'Command is missing. See help to learn more.')
18
- },
19
- handler: async function (argv) {}
20
- })
@@ -1,48 +0,0 @@
1
- import path from 'node:path'
2
- import fs from 'fs-extra'
3
-
4
- /** @type {import('juisy/cli').Command} */
5
- export default new CLI.Command({
6
- command: 'reset',
7
- describe: 'Reset git hooks',
8
- builder (cli) {
9
- return cli
10
- },
11
- async handler (argv) {
12
- // Utils
13
- const { $style, step, substep } = CLI.OutputUtils
14
- const { rootDir, run, abort } = CLI.InterfaceUtils
15
- /**
16
- * Reset git hooks
17
- */
18
- step('Reset git hooks')
19
-
20
- // Create temporary empty configuration file
21
- const tempConfigFilePath = './__TEMP_SIMPLE_GIT_HOOKS_CONFIG__.json' // relative to project root folder
22
- fs.writeFileSync(path.resolve(rootDir, tempConfigFilePath), '{}')
23
-
24
- // Run command with empty configuration
25
- let commandError = false
26
- try {
27
- await run('npx', [
28
- 'simple-git-hooks',
29
- tempConfigFilePath
30
- ], { stdio: 'pipe', cwd: rootDir })
31
- } catch (e) {
32
- commandError = e
33
- }
34
-
35
- // Don't forget to always remove temporary file
36
- fs.unlinkSync(path.resolve(rootDir, tempConfigFilePath))
37
-
38
- // If error
39
- if (commandError) {
40
- substep($style.red('❌ Unable to reset git hooks.'), { last: true })
41
- abort(1) // Abort with error
42
- } else {
43
- // Everything is okay
44
- substep($style.green('✔ Git hooks successfuly reset'), { last: true })
45
- this.log() // blank line
46
- }
47
- }
48
- })
@@ -1,19 +0,0 @@
1
- /** @type {import('juisy/cli').Command} */
2
- export default new CLI.Command({
3
- command: 'sync',
4
- describe: 'Sync git hooks',
5
- builder (cli) {
6
- return cli
7
- },
8
- async handler (argv) {
9
- // Utils
10
- const { step } = CLI.OutputUtils
11
- const { run } = CLI.InterfaceUtils
12
- /**
13
- * Sync git hooks
14
- */
15
- step('Sync git hooks')
16
-
17
- await run('npx', [ 'simple-git-hooks' ])
18
- }
19
- })