@jahia/vite-plugin 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @jahia/vite-plugin
2
+
3
+ A Vite plugin to develop JavaScript Modules for the Jahia platform.
4
+
5
+ This README will be updated soon.
6
+
7
+ ## Installation
8
+
9
+ Using our project creation CLI should set you up correctly. It will ship with good defaults to get you started, but your workflow might need more advanced settings. For that, the `jahia` Vite plugin can take an object of options:
10
+
11
+ ```js
12
+ import { defineConfig } from "vite";
13
+ import jahia from "@jahia/vite-plugin";
14
+ import { spawnSync } from "node:child_process";
15
+
16
+ export default defineConfig({
17
+ plugins: [
18
+ jahia({
19
+ // Client options
20
+ client: {
21
+ input: "./src/client/index.js",
22
+ // /!\ This path is currently hard-coded in the engine loader,
23
+ // it cannot be changed yet.
24
+ output: "./javascript/client/index.js",
25
+ },
26
+
27
+ // Server options
28
+ server: {
29
+ // You can use a glob pattern to match multiple files
30
+ input: "./src/server/index.{js,ts}",
31
+ output: {
32
+ dir: "./javascript/server",
33
+ fileName: "index", // Will produce index.js and index.css
34
+ },
35
+ },
36
+
37
+ // This function is called every time a build succeeds in watch mode
38
+ watchCallback() {
39
+ spawnSync("yarn", ["watch:callback"], { stdio: "inherit" });
40
+ },
41
+ }),
42
+ ],
43
+ });
44
+ ```
@@ -0,0 +1,69 @@
1
+ import { PluginOption } from 'vite';
2
+
3
+ declare function jahia(options?: {
4
+ /** Options for the client-side loader. */
5
+ client?: {
6
+ /** Entrypoint for the client-side bundle. */
7
+ input?: {
8
+ /**
9
+ * Parent directory of the client-side code.
10
+ *
11
+ * @default "./src/client/"
12
+ */
13
+ dir?: string;
14
+ /**
15
+ * Glob pattern(s) used to find all client-side code in `dir`.
16
+ *
17
+ * See [tinyglobby](https://www.npmjs.com/package/tinyglobby) for supported patterns.
18
+ *
19
+ * @default "**‍/*.jsx"
20
+ */
21
+ glob?: string | string[];
22
+ };
23
+ /**
24
+ * Where to put the client-side bundle. It is a directory that will have the same structure as
25
+ * the source directory.
26
+ *
27
+ * @default "./javascript/client/"
28
+ */
29
+ output?: string;
30
+ };
31
+ /** Options for the server-side bundle. */
32
+ server?: {
33
+ /**
34
+ * Entrypoint for the server-side bundle.
35
+ *
36
+ * [Glob patterns are
37
+ * supported.](https://www.npmjs.com/package/@rollup/plugin-multi-entry#supported-input-types)
38
+ *
39
+ * @default "./src/index.{js,ts}"
40
+ */
41
+ input?: string;
42
+ /** Where to put the built server-side bundle. */
43
+ output?: {
44
+ /**
45
+ * Directory where to put the built server-side bundle.
46
+ *
47
+ * @default "./javascript/server/"
48
+ */
49
+ dir?: string;
50
+ /**
51
+ * Base name for the built server-side bundle.
52
+ *
53
+ * Will be appended with '.js' for the JavaScript output and '.css' for the CSS output.
54
+ *
55
+ * @default "index"
56
+ */
57
+ fileName?: string;
58
+ };
59
+ };
60
+ /**
61
+ * Function to execute when the build is complete in watch mode. Can be used to automatically
62
+ * deploy your module to a local Jahia instance.
63
+ *
64
+ * @default undefined
65
+ */
66
+ watchCallback?: () => void | Promise<void>;
67
+ }): PluginOption;
68
+
69
+ export { jahia as default };
package/dist/index.js ADDED
@@ -0,0 +1,224 @@
1
+ import multiEntry from '@rollup/plugin-multi-entry';
2
+ import { createFilter, addExtension } from '@rollup/pluginutils';
3
+ import { extname } from 'node:path';
4
+ import { styleText } from 'node:util';
5
+ import { globSync } from 'tinyglobby';
6
+ import { print } from 'esrap';
7
+ import { walk } from 'zimmerframe';
8
+ import path from 'path';
9
+
10
+ var sharedLibs = {
11
+ // React ships as CJS, so we need our own shims
12
+ // See src/client-javascript/shared-libs/README.md for details
13
+ "react": "./src/client-javascript/shared-libs/react.ts",
14
+ "react/jsx-runtime": "./src/client-javascript/shared-libs/react/jsx-runtime.ts",
15
+ "react-dom/client": "./src/client-javascript/shared-libs/react-dom/client.ts",
16
+ // Packages already in ESM can be copied as-is from node_modules
17
+ "i18next": "i18next",
18
+ "react-i18next": "react-i18next"
19
+ };
20
+
21
+ const insertFilename = (root, prefix) => {
22
+ const filter = createFilter(null, null, {
23
+ resolve: root
24
+ });
25
+ return {
26
+ name: "insert-path",
27
+ transform(code, id) {
28
+ if (!filter(id)) return;
29
+ const ast = walk(this.parse(code), null, {
30
+ // Only target `export default function`
31
+ ExportDefaultDeclaration(node) {
32
+ if (node.declaration.type !== "FunctionDeclaration") return;
33
+ return {
34
+ // export default
35
+ type: "ExportDefaultDeclaration",
36
+ leadingComments: node.leadingComments,
37
+ trailingComments: node.trailingComments,
38
+ range: node.range,
39
+ loc: node.loc,
40
+ declaration: {
41
+ // Object.defineProperty(...)
42
+ type: "CallExpression",
43
+ optional: false,
44
+ callee: {
45
+ type: "MemberExpression",
46
+ computed: false,
47
+ optional: false,
48
+ object: { type: "Identifier", name: "Object" },
49
+ property: { type: "Identifier", name: "defineProperty" }
50
+ },
51
+ arguments: [
52
+ {
53
+ // Original function
54
+ ...node.declaration,
55
+ type: "FunctionExpression"
56
+ },
57
+ { type: "Literal", value: "__filename" },
58
+ {
59
+ // { value: id, enumerable: false }
60
+ type: "ObjectExpression",
61
+ properties: [
62
+ {
63
+ type: "Property",
64
+ computed: false,
65
+ kind: "init",
66
+ method: false,
67
+ shorthand: false,
68
+ key: { type: "Identifier", name: "value" },
69
+ value: { type: "Literal", value: prefix + path.relative(root, id) }
70
+ },
71
+ {
72
+ type: "Property",
73
+ computed: false,
74
+ kind: "init",
75
+ method: false,
76
+ shorthand: false,
77
+ key: { type: "Identifier", name: "enumerable" },
78
+ value: { type: "Literal", value: false }
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ }
84
+ };
85
+ }
86
+ });
87
+ return print(ast);
88
+ }
89
+ };
90
+ };
91
+
92
+ const external = Object.keys(sharedLibs);
93
+ function buildSuccessPlugin(callback) {
94
+ let succeeded = true;
95
+ return {
96
+ name: "build-success-callback",
97
+ buildEnd(error) {
98
+ succeeded = !error;
99
+ },
100
+ async closeBundle() {
101
+ if (succeeded) await callback();
102
+ }
103
+ };
104
+ }
105
+ function jahia(options = {}) {
106
+ return {
107
+ name: "@jahia/vite-plugin",
108
+ /**
109
+ * Configuration hook.
110
+ *
111
+ * Updating the configuration can be done both by mutation or by merging. We use both methods to
112
+ * offer the best experience for the user.
113
+ *
114
+ * @see https://vite.dev/guide/api-plugin.html#config
115
+ */
116
+ config(config) {
117
+ config.builder ??= {};
118
+ config.esbuild ??= { jsx: "automatic" };
119
+ return {
120
+ environments: {
121
+ client: {
122
+ build: {
123
+ lib: {
124
+ // Single entry point for the client, all other files must be imported in this one
125
+ entry: globSync(options.client?.input?.glob ?? "**/*.jsx", {
126
+ cwd: options.client?.input?.dir ?? "./src/client/",
127
+ absolute: true
128
+ }),
129
+ formats: ["es"]
130
+ },
131
+ rollupOptions: {
132
+ output: {
133
+ dir: options.client?.output ?? "./javascript/client/",
134
+ entryFileNames: ({ facadeModuleId, name }) => facadeModuleId ? (
135
+ // Keep the original extension, add .js after it
136
+ `${addExtension(name, extname(facadeModuleId))}.js`
137
+ ) : addExtension(name),
138
+ preserveModules: true,
139
+ preserveModulesRoot: options.client?.input?.dir ?? "./src/client/"
140
+ },
141
+ external,
142
+ plugins: [
143
+ {
144
+ name: "forbid-library",
145
+ resolveId(id) {
146
+ this.debug(id);
147
+ console.log(id);
148
+ if (id === "@jahia/javascript-modules-library") {
149
+ throw new Error(
150
+ `You cannot import '@jahia/javascript-modules-library' in the client bundle`
151
+ );
152
+ }
153
+ }
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ },
159
+ ssr: {
160
+ build: {
161
+ lib: {
162
+ /**
163
+ * Necessary for IIFE format but not used; it's the name given to the global
164
+ * variable that will be created by the IIFE.
165
+ */
166
+ name: "serverBundle",
167
+ entry: options.server?.input ?? "./src/index.{js,ts}",
168
+ fileName: options.server?.output?.fileName ?? "index",
169
+ // Bundle the old way, as an IIFE, to replace libs with globals
170
+ formats: ["iife"]
171
+ },
172
+ rollupOptions: {
173
+ output: {
174
+ dir: options.server?.output?.dir ?? "./javascript/server/",
175
+ // Replace the imports of external libraries with the globals
176
+ globals: Object.fromEntries(
177
+ [
178
+ ...external,
179
+ // This is only available on the server, attempting to import it
180
+ // on the client will throw an error
181
+ "@jahia/javascript-modules-library"
182
+ ].map((lib) => [
183
+ lib,
184
+ // This is how a shared library is imported in the server bundle
185
+ `javascriptModulesLibraryBuilder.getSharedLibrary(${JSON.stringify(lib)})`
186
+ ])
187
+ )
188
+ },
189
+ external: [...external, "@jahia/javascript-modules-library"],
190
+ plugins: [
191
+ multiEntry({
192
+ exports: false,
193
+ entryFileName: `${options.server?.output?.fileName ?? "index"}.js`
194
+ }),
195
+ // Only add the callback plugin in watch mode
196
+ config.build?.watch && options.watchCallback && buildSuccessPlugin(options.watchCallback),
197
+ // Insert filenames in client-side components
198
+ insertFilename(
199
+ options.client?.input?.dir ?? "./src/client/",
200
+ options.client?.output ?? "./javascript/client/"
201
+ )
202
+ ]
203
+ }
204
+ }
205
+ }
206
+ }
207
+ };
208
+ },
209
+ // Needed to run before Vite's default resolver
210
+ enforce: "pre",
211
+ resolveId(id, importer) {
212
+ if (this.environment.name === "client" && id === "@jahia/javascript-modules-library") {
213
+ this.error(
214
+ `
215
+ Cannot import @jahia/javascript-modules-library in the client bundle
216
+ in ${importer}
217
+ ${styleText("bgRedBright", "This module is only available on the server.")}`
218
+ );
219
+ }
220
+ }
221
+ };
222
+ }
223
+
224
+ export { jahia as default };
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');