@jahia/create-module 0.0.9 → 0.5.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 (77) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -3
  3. package/babel.config.cjs +2 -5
  4. package/index.js +95 -87
  5. package/node/node +0 -0
  6. package/node/npm +65 -0
  7. package/node/npm.cmd +20 -0
  8. package/node/npx +65 -0
  9. package/node/npx.cmd +20 -0
  10. package/node/yarn/dist/LICENSE +26 -0
  11. package/node/yarn/dist/README.md +60 -0
  12. package/node/yarn/dist/bin/yarn +35 -0
  13. package/node/yarn/dist/bin/yarn.cmd +2 -0
  14. package/node/yarn/dist/bin/yarn.js +31 -0
  15. package/node/yarn/dist/bin/yarnpkg +2 -0
  16. package/node/yarn/dist/bin/yarnpkg.cmd +2 -0
  17. package/node/yarn/dist/lib/cli.js +154071 -0
  18. package/node/yarn/dist/lib/v8-compile-cache.js +351 -0
  19. package/node/yarn/dist/package.json +28 -0
  20. package/node/yarn/dist/preinstall.js +60 -0
  21. package/package.json +21 -24
  22. package/pom.xml +134 -0
  23. package/sync-version.js +16 -0
  24. package/template/README.md +19 -11
  25. package/template/dotgithub/workflows/build.yml +21 -0
  26. package/template/dotgitignore +3 -9
  27. package/template/dotidea/jsLinters/eslint.xml +6 -0
  28. package/template/dotidea/prettier.xml +7 -0
  29. package/template/dotprettierignore +1 -0
  30. package/template/dotvscode/settings.json +11 -0
  31. package/template/dotyarnrc.yml +1 -0
  32. package/template/eslint.config.js +25 -0
  33. package/template/package.json +41 -43
  34. package/template/prettier.config.js +9 -0
  35. package/template/settings/README.md +3 -1
  36. package/template/settings/import.xml +5 -1
  37. package/template/settings/locales/de.json +2 -2
  38. package/template/settings/locales/en.json +3 -3
  39. package/template/settings/locales/fr.json +2 -2
  40. package/template/src/client/index.jsx +1 -5
  41. package/template/src/server/templates/page/PageHome.tsx +43 -0
  42. package/template/src/server/views/simpleContent/SimpleContentDefault.tsx +16 -0
  43. package/template/static/css/styles.css +7 -7
  44. package/template/tsconfig.json +27 -0
  45. package/template/vite.config.mjs +33 -0
  46. package/tests/create-templatesSet-project.test.js +126 -113
  47. package/.eslintrc.cjs +0 -28
  48. package/.github/ISSUE_TEMPLATE/bug.yml +0 -45
  49. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  50. package/.github/ISSUE_TEMPLATE/epic.md +0 -26
  51. package/.github/ISSUE_TEMPLATE/other.md +0 -8
  52. package/.github/ISSUE_TEMPLATE/release.md +0 -64
  53. package/.github/ISSUE_TEMPLATE/spike.md +0 -19
  54. package/.github/ISSUE_TEMPLATE/story.md +0 -27
  55. package/.github/ISSUE_TEMPLATE/support.yml +0 -40
  56. package/.github/ISSUE_TEMPLATE/tech-day.md +0 -93
  57. package/.github/dependabot.yml +0 -15
  58. package/.github/release.yml +0 -24
  59. package/.github/workflows/delivery-issue-chores.yml +0 -12
  60. package/.github/workflows/on-code-change.yml +0 -50
  61. package/.github/workflows/publish-release.yml +0 -22
  62. package/.yarn/releases/yarn-4.6.0.cjs +0 -934
  63. package/.yarnrc.yml +0 -3
  64. package/template/.babelrc +0 -9
  65. package/template/.yarn/releases/yarn-4.3.1.cjs +0 -894
  66. package/template/.yarnrc.yml +0 -3
  67. package/template/doteslintrc.cjs +0 -30
  68. package/template/dotnpmignore +0 -10
  69. package/template/src/server/components/index.js +0 -1
  70. package/template/src/server/index.js +0 -6
  71. package/template/src/server/templates/index.js +0 -1
  72. package/template/src/server/templates/page/PageHome.jsx +0 -32
  73. package/template/src/server/templates/page/index.js +0 -1
  74. package/template/src/server/views/index.js +0 -1
  75. package/template/src/server/views/simpleContent/SimpleContentDefault.jsx +0 -19
  76. package/template/src/server/views/simpleContent/index.js +0 -1
  77. package/template/webpack.config.js +0 -225
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Jahia Forge - Code Repository
3
+ Copyright (c) 2025 Jahia Forge - Code Repository
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
- # NPM Module template create-module project
1
+ # Javascript Module template create-module project
2
2
 
3
- This project provides an NPM/NPX starter project template to quickly get up and running to create Jahia NPM modules
3
+ This project provides a Javascript module starter project template to quickly get up and running to create Jahia Javascript modules
4
4
 
5
5
  ## Usage
6
6
 
7
7
  npx @jahia/create-module@latest project-name [module-type] [namespace-definitions]
8
8
 
9
- where
9
+ where
10
+
10
11
  - `project-name` (mandatory) can be anything you want to call your project
11
12
  - `module-type` (optional) Can be one of:
12
13
  - `templatesSet`: A collection of templates and components. A template set is required when creating a website.
package/babel.config.cjs CHANGED
@@ -1,6 +1,3 @@
1
1
  module.exports = {
2
- presets: [
3
- '@babel/preset-env',
4
- '@babel/preset-react'
5
- ]
6
- };
2
+ presets: ["@babel/preset-env", "@babel/preset-react"],
3
+ };
package/index.js CHANGED
@@ -2,22 +2,26 @@
2
2
 
3
3
  // Usage: npx @jahia/create-module@latest module-name [namespace]
4
4
 
5
- import fs from 'fs';
6
- import path from 'path';
7
- import {fileURLToPath} from 'url';
8
- import {replaceInFileSync} from 'replace-in-file';
9
- import camelCase from 'camelcase';
10
- import {execSync} from 'child_process';
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import { fileURLToPath } from "url";
8
+ import { replaceInFileSync } from "replace-in-file";
9
+ import camelCase from "camelcase";
11
10
 
12
11
  const __filename = fileURLToPath(import.meta.url);
13
12
  const __dirname = path.dirname(__filename);
14
13
 
15
- // Show help if no argment is provided
16
- // eslint-disable-next-line no-unused-vars
17
- const [nodeCommand, npxCommand, projectName, moduleType = 'module', namespace = camelCase(projectName || '')] = process.argv;
14
+ // Show help if no argument is provided
15
+ const [
16
+ ,
17
+ ,
18
+ projectName,
19
+ moduleType = "module",
20
+ namespace = camelCase(projectName || ""),
21
+ ] = process.argv;
18
22
 
19
23
  if (!projectName) {
20
- console.log(`\x1B[1m## Usage\x1B[0m
24
+ console.log(`\x1B[1m## Usage\x1B[0m
21
25
 
22
26
  npx @jahia/create-module@latest project-name [module-type] [namespace-definitions]
23
27
 
@@ -29,32 +33,32 @@ where
29
33
  - \x1B[3msystem\x1B[0m Critical module for the whole platform .
30
34
  - \x1B[1mnamespace-definitions\x1B[0m (optional) The namespace used for content definitions. Default is the project name in camel case.
31
35
  `);
32
- process.exit(9);
36
+ process.exit(9);
33
37
  }
34
38
 
35
39
  // First let's do some version checks
36
- console.log('Node version detected:', process.versions.node);
37
- const yarnVersion = execSync('yarn --version', {encoding: 'utf8'});
38
- console.log('Yarn version:', yarnVersion);
40
+ console.log("Node version detected:", process.versions.node);
39
41
 
40
42
  // Create a project directory with the project name.
41
43
  const currentDir = process.cwd();
42
44
  const projectDir = path.resolve(currentDir, projectName);
43
- fs.mkdirSync(projectDir, {recursive: true});
45
+ fs.mkdirSync(projectDir, { recursive: true });
44
46
 
45
- console.log(`Creating a new Jahia module project \x1B[1m${projectName}\x1B[0m of type \x1B[1m${moduleType}\x1B[0m and definitions namespace \x1B[1m${namespace}\x1B[0m`);
47
+ console.log(
48
+ `Creating a new Jahia module project \x1B[1m${projectName}\x1B[0m of type \x1B[1m${moduleType}\x1B[0m and definitions namespace \x1B[1m${namespace}\x1B[0m`,
49
+ );
46
50
 
47
51
  // A common approach to building a starter template is to
48
52
  // create a `template` folder which will house the template
49
53
  // and the files we want to create.
50
- const templateDir = path.resolve(__dirname, 'template');
51
- const isTemplatesSet = moduleType === 'templatesSet';
54
+ const templateDir = path.resolve(__dirname, "template");
55
+ const isTemplatesSet = moduleType === "templatesSet";
52
56
  fs.cpSync(templateDir, projectDir, {
53
- recursive: true,
54
- filter: src => {
55
- // The file template-thumbnail.png is only used for the type templatesSet
56
- return (isTemplatesSet || src !== path.join(templateDir, 'settings', 'template-thumbnail.png'));
57
- }
57
+ recursive: true,
58
+ filter: (src) => {
59
+ // The file template-thumbnail.png is only used for the type templatesSet
60
+ return isTemplatesSet || src !== path.join(templateDir, "settings", "template-thumbnail.png");
61
+ },
58
62
  });
59
63
 
60
64
  // Find and replace all markers with the appropriate substitution values
@@ -62,25 +66,25 @@ fs.cpSync(templateDir, projectDir, {
62
66
  const targetFiles = `${projectDir}/**`;
63
67
 
64
68
  try {
65
- replaceInFileSync({
66
- files: targetFiles,
67
- from: /\$\$MODULE_TYPE\$\$/g,
68
- to: moduleType
69
- });
70
-
71
- replaceInFileSync({
72
- files: targetFiles,
73
- from: /\$\$MODULE_NAME\$\$/g,
74
- to: projectName
75
- });
76
-
77
- replaceInFileSync({
78
- files: targetFiles,
79
- from: /\$\$MODULE_NAMESPACE\$\$/g,
80
- to: namespace
81
- });
69
+ replaceInFileSync({
70
+ files: targetFiles,
71
+ from: /\$\$MODULE_TYPE\$\$/g,
72
+ to: moduleType,
73
+ });
74
+
75
+ replaceInFileSync({
76
+ files: targetFiles,
77
+ from: /\$\$MODULE_NAME\$\$/g,
78
+ to: projectName,
79
+ });
80
+
81
+ replaceInFileSync({
82
+ files: targetFiles,
83
+ from: /\$\$MODULE_NAMESPACE\$\$/g,
84
+ to: namespace,
85
+ });
82
86
  } catch (error) {
83
- console.error('Error occurred:', error);
87
+ console.error("Error occurred:", error);
84
88
  }
85
89
 
86
90
  // It is good practice to have dotfiles stored in the
@@ -88,63 +92,67 @@ try {
88
92
  // up by the starter template repository). We can rename
89
93
  // the dotfiles after we have copied them over to the
90
94
  // new project directory.
91
- fs.renameSync(
92
- path.join(projectDir, 'dotgitignore'),
93
- path.join(projectDir, '.gitignore')
94
- );
95
- fs.renameSync(
96
- path.join(projectDir, 'dotnpmignore'),
97
- path.join(projectDir, '.npmignore')
98
- );
99
- fs.renameSync(
100
- path.join(projectDir, 'dotenv'),
101
- path.join(projectDir, '.env')
102
- );
103
- fs.renameSync(
104
- path.join(projectDir, 'doteslintrc.cjs'),
105
- path.join(projectDir, '.eslintrc.cjs')
106
- );
95
+ fs.renameSync(path.join(projectDir, "dotenv"), path.join(projectDir, ".env"));
96
+ fs.renameSync(path.join(projectDir, "dotgitignore"), path.join(projectDir, ".gitignore"));
97
+ fs.renameSync(path.join(projectDir, "dotprettierignore"), path.join(projectDir, ".prettierignore"));
98
+ fs.renameSync(path.join(projectDir, "dotyarnrc.yml"), path.join(projectDir, ".yarnrc.yml"));
99
+ fs.renameSync(path.join(projectDir, "dotgithub"), path.join(projectDir, ".github"));
100
+ fs.renameSync(path.join(projectDir, "dotidea"), path.join(projectDir, ".idea"));
101
+ fs.renameSync(path.join(projectDir, "dotvscode"), path.join(projectDir, ".vscode"));
107
102
 
108
103
  // Rename the resource file to use the project name
109
104
  fs.renameSync(
110
- path.join(projectDir, 'settings', 'resources', 'MODULE_NAME.properties'),
111
- path.join(projectDir, 'settings', 'resources', projectName + '.properties')
105
+ path.join(projectDir, "settings", "resources", "MODULE_NAME.properties"),
106
+ path.join(projectDir, "settings", "resources", projectName + ".properties"),
112
107
  );
113
108
 
114
109
  fs.renameSync(
115
- path.join(projectDir, 'settings', 'resources', 'MODULE_NAME_fr.properties'),
116
- path.join(projectDir, 'settings', 'resources', projectName + '_fr.properties')
110
+ path.join(projectDir, "settings", "resources", "MODULE_NAME_fr.properties"),
111
+ path.join(projectDir, "settings", "resources", projectName + "_fr.properties"),
117
112
  );
118
113
 
119
114
  fs.renameSync(
120
- path.join(projectDir, 'settings', 'content-types-icons', 'MODULE_NAMESPACE_simpleContent.png'),
121
- path.join(projectDir, 'settings', 'content-types-icons', namespace + '_simpleContent.png')
115
+ path.join(projectDir, "settings", "content-types-icons", "MODULE_NAMESPACE_simpleContent.png"),
116
+ path.join(projectDir, "settings", "content-types-icons", namespace + "_simpleContent.png"),
122
117
  );
123
118
 
124
119
  // Create empty directories for static resources and configurations
125
- fs.mkdirSync(path.join(projectDir, 'static', 'css'), {recursive: true});
126
- fs.mkdirSync(path.join(projectDir, 'static', 'images'), {recursive: true});
127
- fs.mkdirSync(path.join(projectDir, 'static', 'javascript'), {recursive: true});
128
- fs.mkdirSync(path.join(projectDir, 'settings', 'configurations'), {recursive: true});
129
- fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms'), {recursive: true});
130
- fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'forms'), {recursive: true});
131
- fs.mkdirSync(path.join(projectDir, 'settings', 'content-editor-forms', 'fieldsets'), {recursive: true});
132
-
133
- // Add the latest @jahia/javascript-modules-library
134
- execSync('yarn add @jahia/javascript-modules-library', {cwd: projectDir});
135
- const javascriptModulesLibraryInfo = execSync('yarn info @jahia/javascript-modules-library version --json', {cwd: projectDir, encoding: 'utf8'});
136
- const javascriptModulesLibraryInfoValue = JSON.parse(javascriptModulesLibraryInfo).value;
137
- console.log(`Added ${javascriptModulesLibraryInfoValue} to the project`);
120
+ fs.mkdirSync(path.join(projectDir, "static", "css"), { recursive: true });
121
+ fs.mkdirSync(path.join(projectDir, "static", "images"), { recursive: true });
122
+ fs.mkdirSync(path.join(projectDir, "static", "javascript"), { recursive: true });
123
+ fs.mkdirSync(path.join(projectDir, "settings", "configurations"), { recursive: true });
124
+ fs.mkdirSync(path.join(projectDir, "settings", "content-editor-forms"), { recursive: true });
125
+ fs.mkdirSync(path.join(projectDir, "settings", "content-editor-forms", "forms"), {
126
+ recursive: true,
127
+ });
128
+ fs.mkdirSync(path.join(projectDir, "settings", "content-editor-forms", "fieldsets"), {
129
+ recursive: true,
130
+ });
131
+
132
+ // Add an empty yarn.lock in case any parent folder is using yarn
133
+ fs.writeFileSync(path.join(projectDir, "yarn.lock"), "", "utf8");
138
134
 
139
135
  console.log(`Created \x1B[1m${projectName}\x1B[0m at \x1B[1m${projectDir}\x1B[0m`);
140
- console.log('Success! Your new project is ready.');
141
- console.log('You can now change into your project and launch "yarn" to install everything to get started.');
142
- console.log('---');
143
- console.log('Available project scripts will then be :');
144
- console.log(' - yarn build : build the project');
145
- console.log(' - yarn deploy : deploy the project. Make sure you have updated the .env file to match your setup if needed.');
146
- console.log(' - yarn watch : will build and watch for file modifications, and deploy automatically when changes are detected. Use CTRL+C to stop watching.');
147
- console.log(' - yarn lint : use to check that your code follows the recommended syntax guidelines. Append --fix to automatically fix most problems.');
148
- console.log(' - yarn test : to test your project. By default only performs yarn lint but you are encouraged to add your own testing system here.');
149
- console.log('---');
150
- console.log('You can also check the documentation available here for more details: https://academy.jahia.com/get-started/developers/templating');
136
+ console.log("Success! Your new project is ready.");
137
+ console.log(
138
+ 'You can now change into your project and launch "yarn" to install everything to get started.',
139
+ );
140
+ console.log("---");
141
+ console.log("Available project scripts will then be :");
142
+ console.log(" - yarn build : build the project");
143
+ console.log(
144
+ " - yarn deploy : deploy the project. Make sure you have updated the .env file to match your setup if needed.",
145
+ );
146
+ console.log(
147
+ " - yarn watch : will build and watch for file modifications, and deploy automatically when changes are detected. Use CTRL+C to stop watching.",
148
+ );
149
+ console.log(
150
+ " - yarn lint : use to check that your code follows the recommended syntax guidelines. Append --fix to automatically fix most problems.",
151
+ );
152
+ console.log(
153
+ " - yarn test : to test your project. By default only performs yarn lint but you are encouraged to add your own testing system here.",
154
+ );
155
+ console.log("---");
156
+ console.log(
157
+ "You can also check the documentation available here for more details: https://academy.jahia.com/get-started/developers/templating",
158
+ );
package/node/node ADDED
Binary file
package/node/npm ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is used by the Node.js installer, which expects the cygwin/mingw
4
+ # shell script to already be present in the npm dependency folder.
5
+
6
+ (set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
7
+
8
+ basedir=`dirname "$0"`
9
+
10
+ case `uname` in
11
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
12
+ esac
13
+
14
+ if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
15
+ IS_WSL="true"
16
+ fi
17
+
18
+ function no_node_dir {
19
+ # if this didn't work, then everything else below will fail
20
+ echo "Could not determine Node.js install directory" >&2
21
+ exit 1
22
+ }
23
+
24
+ NODE_EXE="$basedir/node.exe"
25
+ if ! [ -x "$NODE_EXE" ]; then
26
+ NODE_EXE="$basedir/node"
27
+ fi
28
+ if ! [ -x "$NODE_EXE" ]; then
29
+ NODE_EXE=node
30
+ fi
31
+
32
+ # this path is passed to node.exe, so it needs to match whatever
33
+ # kind of paths Node.js thinks it's using, typically win32 paths.
34
+ CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
35
+ if [ $? -ne 0 ]; then
36
+ # this fails under WSL 1 so add an additional message. we also suppress stderr above
37
+ # because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
38
+ # output redirection properly. See https://github.com/microsoft/WSL/issues/2370
39
+ if [ "$IS_WSL" == "true" ]; then
40
+ echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
41
+ fi
42
+ no_node_dir
43
+ fi
44
+ NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
45
+ NPM_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-cli.js"
46
+ NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
47
+ if [ $? -ne 0 ]; then
48
+ no_node_dir
49
+ fi
50
+ NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
51
+
52
+ # a path that will fail -f test on any posix bash
53
+ NPM_WSL_PATH="/.."
54
+
55
+ # WSL can run Windows binaries, so we have to give it the win32 path
56
+ # however, WSL bash tests against posix paths, so we need to construct that
57
+ # to know if npm is installed globally.
58
+ if [ "$IS_WSL" == "true" ]; then
59
+ NPM_WSL_PATH=`wslpath "$NPM_PREFIX_NPM_CLI_JS"`
60
+ fi
61
+ if [ -f "$NPM_PREFIX_NPM_CLI_JS" ] || [ -f "$NPM_WSL_PATH" ]; then
62
+ NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
63
+ fi
64
+
65
+ "$NODE_EXE" "$NPM_CLI_JS" "$@"
package/node/npm.cmd ADDED
@@ -0,0 +1,20 @@
1
+ :: Created by npm, please don't edit manually.
2
+ @ECHO OFF
3
+
4
+ SETLOCAL
5
+
6
+ SET "NODE_EXE=%~dp0\node.exe"
7
+ IF NOT EXIST "%NODE_EXE%" (
8
+ SET "NODE_EXE=node"
9
+ )
10
+
11
+ SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
12
+ SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
13
+ FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
14
+ SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
15
+ )
16
+ IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
17
+ SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
18
+ )
19
+
20
+ "%NODE_EXE%" "%NPM_CLI_JS%" %*
package/node/npx ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is used by the Node.js installer, which expects the cygwin/mingw
4
+ # shell script to already be present in the npm dependency folder.
5
+
6
+ (set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix
7
+
8
+ basedir=`dirname "$0"`
9
+
10
+ case `uname` in
11
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
12
+ esac
13
+
14
+ if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
15
+ IS_WSL="true"
16
+ fi
17
+
18
+ function no_node_dir {
19
+ # if this didn't work, then everything else below will fail
20
+ echo "Could not determine Node.js install directory" >&2
21
+ exit 1
22
+ }
23
+
24
+ NODE_EXE="$basedir/node.exe"
25
+ if ! [ -x "$NODE_EXE" ]; then
26
+ NODE_EXE="$basedir/node"
27
+ fi
28
+ if ! [ -x "$NODE_EXE" ]; then
29
+ NODE_EXE=node
30
+ fi
31
+
32
+ # this path is passed to node.exe, so it needs to match whatever
33
+ # kind of paths Node.js thinks it's using, typically win32 paths.
34
+ CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
35
+ if [ $? -ne 0 ]; then
36
+ # this fails under WSL 1 so add an additional message. we also suppress stderr above
37
+ # because the actual error raised is not helpful. in WSL 1 node.exe cannot handle
38
+ # output redirection properly. See https://github.com/microsoft/WSL/issues/2370
39
+ if [ "$IS_WSL" == "true" ]; then
40
+ echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
41
+ fi
42
+ no_node_dir
43
+ fi
44
+ NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
45
+ NPX_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npx-cli.js"
46
+ NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
47
+ if [ $? -ne 0 ]; then
48
+ no_node_dir
49
+ fi
50
+ NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
51
+
52
+ # a path that will fail -f test on any posix bash
53
+ NPX_WSL_PATH="/.."
54
+
55
+ # WSL can run Windows binaries, so we have to give it the win32 path
56
+ # however, WSL bash tests against posix paths, so we need to construct that
57
+ # to know if npm is installed globally.
58
+ if [ "$IS_WSL" == "true" ]; then
59
+ NPX_WSL_PATH=`wslpath "$NPM_PREFIX_NPX_CLI_JS"`
60
+ fi
61
+ if [ -f "$NPM_PREFIX_NPX_CLI_JS" ] || [ -f "$NPX_WSL_PATH" ]; then
62
+ NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
63
+ fi
64
+
65
+ "$NODE_EXE" "$NPX_CLI_JS" "$@"
package/node/npx.cmd ADDED
@@ -0,0 +1,20 @@
1
+ :: Created by npm, please don't edit manually.
2
+ @ECHO OFF
3
+
4
+ SETLOCAL
5
+
6
+ SET "NODE_EXE=%~dp0\node.exe"
7
+ IF NOT EXIST "%NODE_EXE%" (
8
+ SET "NODE_EXE=node"
9
+ )
10
+
11
+ SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
12
+ SET "NPX_CLI_JS=%~dp0\node_modules\npm\bin\npx-cli.js"
13
+ FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
14
+ SET "NPM_PREFIX_NPX_CLI_JS=%%F\node_modules\npm\bin\npx-cli.js"
15
+ )
16
+ IF EXIST "%NPM_PREFIX_NPX_CLI_JS%" (
17
+ SET "NPX_CLI_JS=%NPM_PREFIX_NPX_CLI_JS%"
18
+ )
19
+
20
+ "%NODE_EXE%" "%NPX_CLI_JS%" %*
@@ -0,0 +1,26 @@
1
+ BSD 2-Clause License
2
+
3
+ For Yarn software
4
+
5
+ Copyright (c) 2016-present, Yarn Contributors. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,60 @@
1
+ <p align="center">
2
+ <a href="https://yarnpkg.com/">
3
+ <img alt="Yarn" src="https://github.com/yarnpkg/assets/blob/master/yarn-kitten-full.png?raw=true" width="546">
4
+ </a>
5
+ </p>
6
+
7
+ <p align="center">
8
+ Fast, reliable, and secure dependency management.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://circleci.com/gh/yarnpkg/yarn"><img alt="Circle Status" src="https://circleci.com/gh/yarnpkg/yarn.svg?style=shield&circle-token=5f0a78473b0f440afb218bf2b82323cc6b3cb43f"></a>
13
+ <a href="https://ci.appveyor.com/project/kittens/yarn/branch/master"><img alt="Appveyor Status" src="https://ci.appveyor.com/api/projects/status/0xdv8chwe2kmk463?svg=true"></a>
14
+ <a href="https://dev.azure.com/yarnpkg/yarn/_build"><img alt="Azure Pipelines status" src="https://dev.azure.com/yarnpkg/yarn/_apis/build/status/Yarn%20Acceptance%20Tests"></a>
15
+ <a href="https://discord.gg/yarnpkg"><img alt="Discord Chat" src="https://img.shields.io/discord/226791405589233664.svg"></a>
16
+ <a href="http://commitizen.github.io/cz-cli/"><img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg"></a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ **Fast:** Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.
22
+
23
+ **Reliable:** Using a detailed but concise lockfile format and a deterministic algorithm for install operations, Yarn is able to guarantee that any installation that works on one system will work exactly the same on another system.
24
+
25
+ **Secure:** Yarn uses checksums to verify the integrity of every installed package before its code is executed.
26
+
27
+ ## Features
28
+
29
+ * **Offline Mode.** If you've installed a package before, then you can install it again without an internet connection.
30
+ * **Deterministic.** The same dependencies will be installed in the same exact way on any machine, regardless of installation order.
31
+ * **Network Performance.** Yarn efficiently queues requests and avoids request waterfalls in order to maximize network utilization.
32
+ * **Network Resilience.** A single request that fails will not cause the entire installation to fail. Requests are automatically retried upon failure.
33
+ * **Flat Mode.** Yarn resolves mismatched versions of dependencies to a single version to avoid creating duplicates.
34
+ * **More emojis.** 🐈
35
+
36
+ ## Installing Yarn
37
+
38
+ Read the [Installation Guide](https://yarnpkg.com/en/docs/install) on our website for detailed instructions on how to install Yarn.
39
+
40
+ ## Using Yarn
41
+
42
+ Read the [Usage Guide](https://yarnpkg.com/en/docs/usage) on our website for detailed instructions on how to use Yarn.
43
+
44
+ ## Contributing to Yarn
45
+
46
+ Contributions are always welcome, no matter how large or small. Substantial feature requests should be proposed as an [RFC](https://github.com/yarnpkg/rfcs). Before contributing, please read the [code of conduct](CODE_OF_CONDUCT.md).
47
+
48
+ See [Contributing](https://yarnpkg.com/org/contributing/).
49
+
50
+ ## Prior art
51
+
52
+ Yarn wouldn't exist if it wasn't for excellent prior art. Yarn has been inspired by the following projects:
53
+
54
+ - [Bundler](https://github.com/bundler/bundler)
55
+ - [Cargo](https://github.com/rust-lang/cargo)
56
+ - [npm](https://github.com/npm/cli)
57
+
58
+ ## Credits
59
+
60
+ Thanks to [Sam Holmes](https://github.com/samholmes) for donating the npm package name!
@@ -0,0 +1,35 @@
1
+ #!/bin/sh
2
+ argv0=$(echo "$0" | sed -e 's,\\,/,g')
3
+ basedir=$(dirname "$(readlink "$0" || echo "$argv0")")
4
+
5
+ case "$(uname -s)" in
6
+ Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";;
7
+ Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");;
8
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
9
+ *MSYS*) basedir=`cygpath -w "$basedir"`;;
10
+ esac
11
+
12
+ command_exists() {
13
+ command -v "$1" >/dev/null 2>&1;
14
+ }
15
+
16
+ if command_exists node; then
17
+ if [ "$YARN_FORCE_WINPTY" = 1 ] || command_exists winpty && test -t 1; then
18
+ winpty node "$basedir/yarn.js" "$@"
19
+ else
20
+ exec node "$basedir/yarn.js" "$@"
21
+ fi
22
+ ret=$?
23
+ # Debian and Ubuntu use "nodejs" as the name of the binary, not "node", so we
24
+ # search for that too. See:
25
+ # https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
26
+ # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907
27
+ elif command_exists nodejs; then
28
+ exec nodejs "$basedir/yarn.js" "$@"
29
+ ret=$?
30
+ else
31
+ >&2 echo 'Yarn requires Node.js 4.0 or higher to be installed.'
32
+ ret=1
33
+ fi
34
+
35
+ exit $ret
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ node "%~dp0\yarn.js" %*
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable no-var */
4
+ /* eslint-disable flowtype/require-valid-file-annotation */
5
+ 'use strict';
6
+
7
+ var ver = process.versions.node;
8
+ var majorVer = parseInt(ver.split('.')[0], 10);
9
+
10
+ if (majorVer < 4) {
11
+ console.error('Node version ' + ver + ' is not supported, please use Node.js 4.0 or higher.');
12
+ process.exit(1); // eslint-disable-line no-process-exit
13
+ } else {
14
+ try {
15
+ require(__dirname + '/../lib/v8-compile-cache.js');
16
+ } catch (err) {
17
+ // We don't have/need this on legacy builds and dev builds
18
+ }
19
+
20
+ // Just requiring this package will trigger a yarn run since the
21
+ // `require.main === module` check inside `cli/index.js` will always
22
+ // be truthy when built with webpack :(
23
+ // `lib/cli` may be `lib/cli/index.js` or `lib/cli.js` depending on the build.
24
+ var cli = require(__dirname + '/../lib/cli');
25
+ if (!cli.autoRun) {
26
+ cli.default().catch(function(error) {
27
+ console.error(error.stack || error.message || error);
28
+ process.exitCode = 1;
29
+ });
30
+ }
31
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('./yarn.js');
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ "%~dp0\yarn.cmd" %*