@jahia/create-module 0.0.10 → 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.
- package/LICENSE +1 -1
- package/README.md +3 -2
- package/babel.config.cjs +2 -5
- package/index.js +93 -79
- package/node/node +0 -0
- package/node/npm +65 -0
- package/node/npm.cmd +20 -0
- package/node/npx +65 -0
- package/node/npx.cmd +20 -0
- package/node/yarn/dist/LICENSE +26 -0
- package/node/yarn/dist/README.md +60 -0
- package/node/yarn/dist/bin/yarn +35 -0
- package/node/yarn/dist/bin/yarn.cmd +2 -0
- package/node/yarn/dist/bin/yarn.js +31 -0
- package/node/yarn/dist/bin/yarnpkg +2 -0
- package/node/yarn/dist/bin/yarnpkg.cmd +2 -0
- package/node/yarn/dist/lib/cli.js +154071 -0
- package/node/yarn/dist/lib/v8-compile-cache.js +351 -0
- package/node/yarn/dist/package.json +28 -0
- package/node/yarn/dist/preinstall.js +60 -0
- package/package.json +21 -24
- package/pom.xml +134 -0
- package/sync-version.js +16 -0
- package/template/README.md +18 -10
- package/template/dotgithub/workflows/build.yml +21 -0
- package/template/dotgitignore +3 -9
- package/template/dotidea/jsLinters/eslint.xml +6 -0
- package/template/dotidea/prettier.xml +7 -0
- package/template/dotprettierignore +1 -0
- package/template/dotvscode/settings.json +11 -0
- package/template/dotyarnrc.yml +1 -0
- package/template/eslint.config.js +25 -0
- package/template/package.json +41 -44
- package/template/prettier.config.js +9 -0
- package/template/settings/README.md +3 -1
- package/template/settings/import.xml +5 -1
- package/template/settings/locales/de.json +2 -2
- package/template/settings/locales/en.json +3 -3
- package/template/settings/locales/fr.json +2 -2
- package/template/src/client/index.jsx +1 -5
- package/template/src/server/templates/page/PageHome.tsx +43 -0
- package/template/src/server/views/simpleContent/SimpleContentDefault.tsx +16 -0
- package/template/static/css/styles.css +7 -7
- package/template/tsconfig.json +27 -0
- package/template/vite.config.mjs +33 -0
- package/tests/create-templatesSet-project.test.js +126 -114
- package/.eslintrc.cjs +0 -28
- package/.github/ISSUE_TEMPLATE/bug.yml +0 -45
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/epic.md +0 -26
- package/.github/ISSUE_TEMPLATE/other.md +0 -8
- package/.github/ISSUE_TEMPLATE/release.md +0 -74
- package/.github/ISSUE_TEMPLATE/spike.md +0 -19
- package/.github/ISSUE_TEMPLATE/story.md +0 -27
- package/.github/ISSUE_TEMPLATE/support.yml +0 -40
- package/.github/ISSUE_TEMPLATE/tech-day.md +0 -93
- package/.github/dependabot.yml +0 -15
- package/.github/release.yml +0 -24
- package/.github/workflows/delivery-issue-chores.yml +0 -12
- package/.github/workflows/on-code-change.yml +0 -50
- package/.github/workflows/publish-release.yml +0 -22
- package/.yarn/releases/yarn-4.6.0.cjs +0 -934
- package/.yarnrc.yml +0 -3
- package/template/.babelrc +0 -9
- package/template/.yarn/releases/yarn-4.3.1.cjs +0 -894
- package/template/.yarnrc.yml +0 -3
- package/template/doteslintrc.cjs +0 -30
- package/template/dotnpmignore +0 -10
- package/template/src/server/components/index.js +0 -1
- package/template/src/server/index.js +0 -6
- package/template/src/server/templates/index.js +0 -1
- package/template/src/server/templates/page/PageHome.jsx +0 -32
- package/template/src/server/templates/page/index.js +0 -1
- package/template/src/server/views/index.js +0 -1
- package/template/src/server/views/simpleContent/SimpleContentDefault.jsx +0 -19
- package/template/src/server/views/simpleContent/index.js +0 -1
- package/template/webpack.config.js +0 -225
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
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
1
|
# Javascript Module template create-module project
|
|
2
2
|
|
|
3
|
-
This project provides
|
|
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
package/index.js
CHANGED
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
// Usage: npx @jahia/create-module@latest module-name [namespace]
|
|
4
4
|
|
|
5
|
-
import fs from
|
|
6
|
-
import path from
|
|
7
|
-
import {fileURLToPath} from
|
|
8
|
-
import {replaceInFileSync} from
|
|
9
|
-
import camelCase from
|
|
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
10
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
13
|
|
|
14
|
-
// Show help if no
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// Show help if no argument is provided
|
|
15
|
+
const [
|
|
16
|
+
,
|
|
17
|
+
,
|
|
18
|
+
projectName,
|
|
19
|
+
moduleType = "module",
|
|
20
|
+
namespace = camelCase(projectName || ""),
|
|
21
|
+
] = process.argv;
|
|
17
22
|
|
|
18
23
|
if (!projectName) {
|
|
19
|
-
|
|
24
|
+
console.log(`\x1B[1m## Usage\x1B[0m
|
|
20
25
|
|
|
21
26
|
npx @jahia/create-module@latest project-name [module-type] [namespace-definitions]
|
|
22
27
|
|
|
@@ -28,30 +33,32 @@ where
|
|
|
28
33
|
- \x1B[3msystem\x1B[0m Critical module for the whole platform .
|
|
29
34
|
- \x1B[1mnamespace-definitions\x1B[0m (optional) The namespace used for content definitions. Default is the project name in camel case.
|
|
30
35
|
`);
|
|
31
|
-
|
|
36
|
+
process.exit(9);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
// First let's do some version checks
|
|
35
|
-
console.log(
|
|
40
|
+
console.log("Node version detected:", process.versions.node);
|
|
36
41
|
|
|
37
42
|
// Create a project directory with the project name.
|
|
38
43
|
const currentDir = process.cwd();
|
|
39
44
|
const projectDir = path.resolve(currentDir, projectName);
|
|
40
|
-
fs.mkdirSync(projectDir, {recursive: true});
|
|
45
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
41
46
|
|
|
42
|
-
console.log(
|
|
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
|
+
);
|
|
43
50
|
|
|
44
51
|
// A common approach to building a starter template is to
|
|
45
52
|
// create a `template` folder which will house the template
|
|
46
53
|
// and the files we want to create.
|
|
47
|
-
const templateDir = path.resolve(__dirname,
|
|
48
|
-
const isTemplatesSet = moduleType ===
|
|
54
|
+
const templateDir = path.resolve(__dirname, "template");
|
|
55
|
+
const isTemplatesSet = moduleType === "templatesSet";
|
|
49
56
|
fs.cpSync(templateDir, projectDir, {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
+
},
|
|
55
62
|
});
|
|
56
63
|
|
|
57
64
|
// Find and replace all markers with the appropriate substitution values
|
|
@@ -59,25 +66,25 @@ fs.cpSync(templateDir, projectDir, {
|
|
|
59
66
|
const targetFiles = `${projectDir}/**`;
|
|
60
67
|
|
|
61
68
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
});
|
|
79
86
|
} catch (error) {
|
|
80
|
-
|
|
87
|
+
console.error("Error occurred:", error);
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
// It is good practice to have dotfiles stored in the
|
|
@@ -85,60 +92,67 @@ try {
|
|
|
85
92
|
// up by the starter template repository). We can rename
|
|
86
93
|
// the dotfiles after we have copied them over to the
|
|
87
94
|
// new project directory.
|
|
88
|
-
fs.renameSync(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
92
|
-
fs.renameSync(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
96
|
-
fs.renameSync(
|
|
97
|
-
path.join(projectDir, 'dotenv'),
|
|
98
|
-
path.join(projectDir, '.env')
|
|
99
|
-
);
|
|
100
|
-
fs.renameSync(
|
|
101
|
-
path.join(projectDir, 'doteslintrc.cjs'),
|
|
102
|
-
path.join(projectDir, '.eslintrc.cjs')
|
|
103
|
-
);
|
|
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"));
|
|
104
102
|
|
|
105
103
|
// Rename the resource file to use the project name
|
|
106
104
|
fs.renameSync(
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
path.join(projectDir, "settings", "resources", "MODULE_NAME.properties"),
|
|
106
|
+
path.join(projectDir, "settings", "resources", projectName + ".properties"),
|
|
109
107
|
);
|
|
110
108
|
|
|
111
109
|
fs.renameSync(
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
path.join(projectDir, "settings", "resources", "MODULE_NAME_fr.properties"),
|
|
111
|
+
path.join(projectDir, "settings", "resources", projectName + "_fr.properties"),
|
|
114
112
|
);
|
|
115
113
|
|
|
116
114
|
fs.renameSync(
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
path.join(projectDir, "settings", "content-types-icons", "MODULE_NAMESPACE_simpleContent.png"),
|
|
116
|
+
path.join(projectDir, "settings", "content-types-icons", namespace + "_simpleContent.png"),
|
|
119
117
|
);
|
|
120
118
|
|
|
121
119
|
// Create empty directories for static resources and configurations
|
|
122
|
-
fs.mkdirSync(path.join(projectDir,
|
|
123
|
-
fs.mkdirSync(path.join(projectDir,
|
|
124
|
-
fs.mkdirSync(path.join(projectDir,
|
|
125
|
-
fs.mkdirSync(path.join(projectDir,
|
|
126
|
-
fs.mkdirSync(path.join(projectDir,
|
|
127
|
-
fs.mkdirSync(path.join(projectDir,
|
|
128
|
-
|
|
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
|
+
});
|
|
129
131
|
|
|
130
132
|
// Add an empty yarn.lock in case any parent folder is using yarn
|
|
131
|
-
fs.writeFileSync(path.join(projectDir,
|
|
133
|
+
fs.writeFileSync(path.join(projectDir, "yarn.lock"), "", "utf8");
|
|
132
134
|
|
|
133
135
|
console.log(`Created \x1B[1m${projectName}\x1B[0m at \x1B[1m${projectDir}\x1B[0m`);
|
|
134
|
-
console.log(
|
|
135
|
-
console.log(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
console.log(
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(
|
|
141
|
-
console.log(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
console.log(
|
|
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,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
|
+
}
|