create-tateru-cli 0.1.0

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/lib/cli/cli.js +85 -0
  4. package/lib/index.js +103 -0
  5. package/package.json +46 -0
  6. package/templates/template-gulp-vanilla/.babelrc +12 -0
  7. package/templates/template-gulp-vanilla/.editorconfig +23 -0
  8. package/templates/template-gulp-vanilla/.eslintignore +2 -0
  9. package/templates/template-gulp-vanilla/.eslintrc.js +19 -0
  10. package/templates/template-gulp-vanilla/.gitattributes +12 -0
  11. package/templates/template-gulp-vanilla/.gitlab-ci.yml +43 -0
  12. package/templates/template-gulp-vanilla/LICENSE +21 -0
  13. package/templates/template-gulp-vanilla/README.md +1 -0
  14. package/templates/template-gulp-vanilla/gulpfile.js +74 -0
  15. package/templates/template-gulp-vanilla/package-lock.json +8706 -0
  16. package/templates/template-gulp-vanilla/package.json +49 -0
  17. package/templates/template-gulp-vanilla/postcss.config.js +5 -0
  18. package/templates/template-gulp-vanilla/public/assets/favicon/android-chrome-192x192.png +0 -0
  19. package/templates/template-gulp-vanilla/public/assets/favicon/android-chrome-512x512.png +0 -0
  20. package/templates/template-gulp-vanilla/public/assets/favicon/apple-touch-icon.png +0 -0
  21. package/templates/template-gulp-vanilla/public/assets/favicon/favicon-16x16.png +0 -0
  22. package/templates/template-gulp-vanilla/public/assets/favicon/favicon-32x32.png +0 -0
  23. package/templates/template-gulp-vanilla/public/assets/favicon/favicon.ico +0 -0
  24. package/templates/template-gulp-vanilla/src/assets/images/content/.gitkeep +0 -0
  25. package/templates/template-gulp-vanilla/src/assets/images/share/homepage.png +0 -0
  26. package/templates/template-gulp-vanilla/src/assets/images/theme/.gitkeep +0 -0
  27. package/templates/template-gulp-vanilla/src/assets/js/homepage.js +1 -0
  28. package/templates/template-gulp-vanilla/src/assets/js/services/analyticsServices.js +18 -0
  29. package/templates/template-gulp-vanilla/src/assets/js/utils/asyncForLoop.js +21 -0
  30. package/templates/template-gulp-vanilla/src/assets/js/utils/sleep.js +7 -0
  31. package/templates/template-gulp-vanilla/src/assets/scss/main.scss +6 -0
  32. package/templates/template-gulp-vanilla/src/assets/scss/src/_core.scss +63 -0
  33. package/templates/template-gulp-vanilla/src/assets/scss/src/_functions.scss +21 -0
  34. package/templates/template-gulp-vanilla/src/assets/scss/src/_mixins.scss +1 -0
  35. package/templates/template-gulp-vanilla/src/assets/scss/src/_variables.scss +13 -0
  36. package/templates/template-gulp-vanilla/src/assets/svg/heart-solid.svg +3 -0
  37. package/templates/template-gulp-vanilla/src/assets/svg/source.svg +3 -0
  38. package/templates/template-gulp-vanilla/src/translations/cs.json +8 -0
  39. package/templates/template-gulp-vanilla/src/twig/layouts/layout.html.twig +150 -0
  40. package/templates/template-gulp-vanilla/src/twig/views/_error-404.html.twig +16 -0
  41. package/templates/template-gulp-vanilla/src/twig/views/homepage.html.twig +21 -0
  42. package/templates/template-gulp-vanilla/src/twig/views/humans.txt.twig +21 -0
  43. package/templates/template-gulp-vanilla/src/twig/views/robots.txt.twig +4 -0
  44. package/templates/template-gulp-vanilla/src/twig/views/site.webmanifest.twig +23 -0
  45. package/templates/template-gulp-vanilla/src/twig/views/sitemap.html.twig +22 -0
  46. package/templates/template-gulp-vanilla/tasks/browser-sync.js +3 -0
  47. package/templates/template-gulp-vanilla/tasks/clean.js +10 -0
  48. package/templates/template-gulp-vanilla/tasks/css.js +20 -0
  49. package/templates/template-gulp-vanilla/tasks/helpers/config.js +5 -0
  50. package/templates/template-gulp-vanilla/tasks/helpers/logger.js +79 -0
  51. package/templates/template-gulp-vanilla/tasks/images.js +12 -0
  52. package/templates/template-gulp-vanilla/tasks/minify-css.js +21 -0
  53. package/templates/template-gulp-vanilla/tasks/public-assets.js +11 -0
  54. package/templates/template-gulp-vanilla/tasks/tateru.js +25 -0
  55. package/templates/template-gulp-vanilla/tasks/watch.js +45 -0
  56. package/templates/template-gulp-vanilla/tasks/webpack.js +93 -0
  57. package/templates/template-gulp-vanilla/tateru.config.json +111 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Daniel Sitek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Create Tateru CLI project
2
+
3
+ Simplest way to create a new project using [tateru-cli](https://github.com/danielsitek/tateru-cli).
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ npm create tateru-cli@latest
9
+ ```
10
+
11
+ You can also specify project name and template via additional command line options.
12
+
13
+ ```sh
14
+ npm create tateru-cli@latest -- --template gulp-vanilla
15
+ ```
16
+
17
+ ```sh
18
+ npm create tateru-cli@latest -- --template gulp-vanilla project-name
19
+ ```
20
+
21
+ You can use `.` for the name of the project to be created in the current directory.
22
+
23
+ Currently supported templates include:
24
+
25
+ - `gulp-vanilla`
26
+
27
+ ## Notes
28
+
29
+ - If the destination directory is not empty, the script will exit with an error.
30
+ - Ensure the template name is valid; otherwise, the script will notify you.
package/lib/cli/cli.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.commands = commands;
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const DEFAULT_TEMPLATE_NAME = 'gulp-vanilla';
10
+ const DEFAULT_DIRECTORY = 'tateru-cli-starter';
11
+ const HELP_MESSAGE = `
12
+ Create a new Tateru CLI project with ease.
13
+
14
+ Usage:
15
+ npx create-tateru-cli [OPTIONS] [ARGS] [DIRECTORY]
16
+
17
+ Options:
18
+ -t, --template NAME Set build environment (dev or prod). Default is dev.
19
+ -h, --help Display help and usage details.
20
+ -V, --version Display Tateru CLI version.
21
+
22
+ Available templates:
23
+ gulp-vanilla Basic template with gulp workflow.
24
+ `;
25
+ /**
26
+ * Prints the help message.
27
+ */
28
+ function printHelp() {
29
+ console.log(HELP_MESSAGE);
30
+ }
31
+ /**
32
+ * Parses command-line arguments and returns options.
33
+ * If --help or --version is provided, it prints output and exits the process.
34
+ *
35
+ * @param basePath The base path of the project. Used to locale package.json file.
36
+ */
37
+ function commands(basePath) {
38
+ return new Promise((resolve, reject) => {
39
+ const args = process.argv.slice(2);
40
+ const options = {
41
+ template: DEFAULT_TEMPLATE_NAME,
42
+ directory: DEFAULT_DIRECTORY,
43
+ };
44
+ // Get package.json data
45
+ const packageJsonPath = node_path_1.default.resolve(basePath, 'package.json');
46
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf-8'));
47
+ for (let i = 0; i < args.length; i++) {
48
+ const arg = args[i];
49
+ switch (arg) {
50
+ case '--help':
51
+ case '-h':
52
+ printHelp();
53
+ resolve(null);
54
+ break;
55
+ case '--version':
56
+ case '-V':
57
+ console.log(packageJson.version);
58
+ resolve(null);
59
+ break;
60
+ case '--template':
61
+ case '-t':
62
+ if (args[i + 1] && !args[i + 1].startsWith('-')) {
63
+ options.template = args[i + 1] || DEFAULT_TEMPLATE_NAME;
64
+ i++;
65
+ }
66
+ else {
67
+ console.error('Error: Missing value for --template.');
68
+ reject();
69
+ }
70
+ break;
71
+ default:
72
+ if (arg.startsWith('-')) {
73
+ console.error(`Error: Unknown option "${arg}"\n`);
74
+ console.log(`Run "npm create tateru-cli@latest -- --help" to see available options.\n`);
75
+ reject();
76
+ }
77
+ if (!arg.startsWith('-')) {
78
+ options.directory = arg;
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ resolve(options);
84
+ });
85
+ }
package/lib/index.js ADDED
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const promises_1 = require("node:fs/promises");
18
+ const node_fs_1 = require("node:fs");
19
+ const cli_1 = require("./cli/cli");
20
+ const promises_2 = __importDefault(require("node:readline/promises"));
21
+ const getTemplatePath = (template) => {
22
+ return node_path_1.default.resolve(__dirname, '..', 'templates', `template-${template}`);
23
+ };
24
+ const getDestinationPath = (directory) => {
25
+ return node_path_1.default.resolve(process.cwd(), directory);
26
+ };
27
+ const validateInputs = (template, directory) => {
28
+ if (!template) {
29
+ throw new Error('Error: Template name is required.');
30
+ }
31
+ if (!directory) {
32
+ throw new Error('Error: Destination directory is required.');
33
+ }
34
+ };
35
+ const ensureDirectoryEmpty = (directory) => __awaiter(void 0, void 0, void 0, function* () {
36
+ if ((0, node_fs_1.existsSync)(directory)) {
37
+ const files = yield (0, promises_1.readdir)(directory);
38
+ if (files.length > 0) {
39
+ const rl = promises_2.default.createInterface({
40
+ input: process.stdin,
41
+ output: process.stdout,
42
+ });
43
+ const answer = yield rl.question(`Warning: Destination directory "${directory}" is not empty. Do you want to continue? (y/N): `);
44
+ rl.close();
45
+ if (answer.toLowerCase() !== 'y') {
46
+ throw new Error('Operation aborted.');
47
+ }
48
+ }
49
+ }
50
+ else {
51
+ yield (0, promises_1.mkdir)(directory, { recursive: true });
52
+ }
53
+ });
54
+ const copyTemplate = (templatePath, destinationPath) => __awaiter(void 0, void 0, void 0, function* () {
55
+ try {
56
+ yield (0, promises_1.cp)(templatePath, destinationPath, { recursive: true });
57
+ }
58
+ catch (error) {
59
+ throw new Error([
60
+ 'Error copying template:',
61
+ error.message,
62
+ ].toString());
63
+ }
64
+ });
65
+ const beginMessage = (template, directory) => {
66
+ return `
67
+ Copying template "${template}" to destination "${directory}"...
68
+ `;
69
+ };
70
+ const doneMessage = (directory) => {
71
+ return `
72
+ Done. Template successfully copied. Now run:
73
+
74
+ cd ${directory}
75
+ npm install
76
+ npm start
77
+ `;
78
+ };
79
+ const init = () => __awaiter(void 0, void 0, void 0, function* () {
80
+ try {
81
+ const result = yield (0, cli_1.commands)(node_path_1.default.resolve(__dirname, '..'));
82
+ if (!result) {
83
+ process.exit(0);
84
+ return;
85
+ }
86
+ const { template, directory } = result;
87
+ validateInputs(template, directory);
88
+ console.log(beginMessage(template, directory));
89
+ const templatePath = getTemplatePath(template);
90
+ const destinationPath = getDestinationPath(directory);
91
+ if (!(0, node_fs_1.existsSync)(templatePath)) {
92
+ throw new Error(`Error: Template "${template}" not found.`);
93
+ }
94
+ yield ensureDirectoryEmpty(destinationPath);
95
+ yield copyTemplate(templatePath, destinationPath);
96
+ console.log(doneMessage(directory));
97
+ }
98
+ catch (error) {
99
+ console.error('Unexpected error:', error.message);
100
+ process.exit(1);
101
+ }
102
+ });
103
+ init();
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "create-tateru-cli",
3
+ "description": "Create basic Tateru CLI project from template files",
4
+ "version": "0.1.0",
5
+ "bin": {
6
+ "create-tateru-cli": "./lib/index.js"
7
+ },
8
+ "files": [
9
+ "lib",
10
+ "templates",
11
+ "README.md"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "clean": "rm -rf lib",
16
+ "typecheck": "tsc --noEmit",
17
+ "prepack": "npm run clean && npm run build"
18
+ },
19
+ "keywords": [
20
+ "tateru-cli",
21
+ "static-site-generator",
22
+ "static-site",
23
+ "create-tateru-cli"
24
+ ],
25
+ "author": {
26
+ "name": "Daniel Sitek",
27
+ "email": "dan.sitek@gmail.com",
28
+ "url": "https://danielsitek.cz"
29
+ },
30
+ "license": "MIT",
31
+ "engines": {
32
+ "node": ">=14"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "20.11",
36
+ "typescript": "^5.8.2"
37
+ },
38
+ "homepage": "https://github.com/danielsitek/tateru-create-tateru-cli#readme",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/danielsitek/tateru-create-tateru-cli.git"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/danielsitek/tateru-create-tateru-cli/issues"
45
+ }
46
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "targets": {
7
+ "node": "current"
8
+ }
9
+ }
10
+ ]
11
+ ]
12
+ }
@@ -0,0 +1,23 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ indent_style = space
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.{js,jsx,ts,tsx,vue}]
13
+ indent_size = 2
14
+ quote_type = single
15
+
16
+ [*.{json,yml,babelrc}]
17
+ indent_size = 2
18
+
19
+ [*.{twig,html,svg}]
20
+ indent_size = 4
21
+
22
+ [*.{scss,css}]
23
+ indent_size = 4
@@ -0,0 +1,2 @@
1
+ node_modules/**/*
2
+ dist/**/*
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ 'env': {
3
+ 'browser': true,
4
+ 'es6': true,
5
+ 'node': true,
6
+ },
7
+ 'globals': {
8
+ 'Atomics': 'readonly',
9
+ 'SharedArrayBuffer': 'readonly',
10
+ },
11
+ 'parserOptions': {
12
+ 'ecmaVersion': 2018,
13
+ 'sourceType': 'module',
14
+ },
15
+ 'rules': {
16
+ quotes: ['error', 'single', { 'allowTemplateLiterals': true }],
17
+ indent: ['error', 2],
18
+ }
19
+ };
@@ -0,0 +1,12 @@
1
+ # Set default behaviour to automatically normalize line endings.
2
+ * text=auto
3
+
4
+ # Force bash scripts to always use lf line endings so that if a repo is accessed
5
+ # in Unix via a file share from Windows, the scripts will work.
6
+ *.sh text eol=lf
7
+
8
+ *.js eol=lf
9
+ *.jsx eol=lf
10
+ *.json eol=lf
11
+ *.ts eol=lf
12
+ *.vue eol=lf
@@ -0,0 +1,43 @@
1
+ image: node:14
2
+
3
+ stages:
4
+ - setup
5
+ - build
6
+ - deploy
7
+
8
+ cache:
9
+ key: ${CI_COMMIT_REF_SLUG}
10
+ paths:
11
+ - node_modules
12
+
13
+ # Setup Stage
14
+ setup:
15
+ stage: setup
16
+ script:
17
+ - npm ci
18
+ only:
19
+ - master
20
+ - merge_requests
21
+
22
+ # Build Stage
23
+ build:website:
24
+ stage: build
25
+ artifacts:
26
+ name: "build-website-{$CI_COMMIT_REF_SLUG}-{$CI_COMMIT_SHORT_SHA}"
27
+ paths:
28
+ - dist
29
+ script:
30
+ - npm run build:prod
31
+ only:
32
+ - master
33
+ - merge_requests
34
+
35
+ # Deploy Stage
36
+ deploy:production:
37
+ stage: deploy
38
+ environment:
39
+ name: production
40
+ only:
41
+ - master
42
+ script:
43
+ - echo "Deploy to Production"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Daniel Sitek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ # tateru-starter
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @link https://github.com/gulpjs/gulp/tree/master/docs/recipes
5
+ */
6
+
7
+ const { ENV_DEVELOPMENT, ENV_PRODUCTION } = require('./tasks/helpers/config');
8
+ const { parallel, series } = require('gulp');
9
+ const clean = require('./tasks/clean');
10
+ const css = require('./tasks/css');
11
+ const images = require('./tasks/images');
12
+ const minifyCss = require('./tasks/minify-css');
13
+ const publicAssets = require('./tasks/public-assets');
14
+ const tateru = require('./tasks/tateru');
15
+ const watch = require('./tasks/watch');
16
+ const webpack = require('./tasks/webpack');
17
+
18
+ process.env.NODE_ENV = ENV_DEVELOPMENT;
19
+
20
+ const js = function js(cb) {
21
+ return series(
22
+ webpack,
23
+ )(cb);
24
+ }
25
+
26
+ const templates = function templates(cb) {
27
+ return series(
28
+ publicAssets,
29
+ tateru,
30
+ )(cb);
31
+ }
32
+
33
+ const build = function build(cb) {
34
+ return series(
35
+ clean,
36
+ parallel(
37
+ css,
38
+ images,
39
+ js,
40
+ templates,
41
+ ),
42
+ )(cb);
43
+ }
44
+
45
+ const dev = function dev(cb) {
46
+ process.env.NODE_ENV = ENV_DEVELOPMENT;
47
+
48
+ return series(
49
+ build,
50
+ watch,
51
+ )(cb);
52
+ };
53
+
54
+ const prod = function prod(cb) {
55
+ process.env.NODE_ENV = ENV_PRODUCTION;
56
+
57
+ return series(
58
+ build,
59
+ minifyCss,
60
+ )(cb);
61
+ };
62
+
63
+ module.exports = {
64
+ build,
65
+ clean,
66
+ css,
67
+ default: dev,
68
+ images,
69
+ js,
70
+ prod,
71
+ publicAssets,
72
+ templates,
73
+ watch,
74
+ }