Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Windows paths #33

Merged
merged 33 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cf63763
Base work for portable path
Embraser01 Mar 19, 2019
3ea7ac5
Add conversion where needed (still missing some!)
Embraser01 Mar 20, 2019
ca12605
Got it to work on Windows!
Embraser01 Mar 20, 2019
9d9af0e
Convert to portable path when calling 'yarn <path> install'
Embraser01 Mar 20, 2019
e7f88b3
Update config.ts
arcanis Mar 20, 2019
5afdbfe
Use posix where possible
Embraser01 Mar 20, 2019
9d8c602
Use xfs in json-proxy instead of native fs
Embraser01 Mar 20, 2019
9f7baa7
Fix berry json proxy dependencies
Embraser01 Mar 20, 2019
293d4c4
Handle more special cases (globby, pnp), activate Windows Pipeline
Embraser01 Mar 22, 2019
08434df
Fix PATH env variable when spawn process
Embraser01 Mar 22, 2019
91da8f7
Fix azure yaml
Embraser01 Mar 22, 2019
9e2c73a
Fixes plugin loading
arcanis Mar 22, 2019
a84f28a
Updates the checked-in build
Mar 22, 2019
fd90c88
Fixes yarn-path execution
Mar 22, 2019
15e5a14
Debug: Adds logging to findZip
Mar 22, 2019
1006c08
Revert "Debug: Adds logging to findZip"
Mar 22, 2019
06f4cad
Enforces symlinks on Windows
Mar 22, 2019
935ef94
Fixes the cmd scripts
Mar 22, 2019
47996f1
Adds a retry for EBUSY and ENOTEMPTY
Mar 22, 2019
e5cc92a
Fixes process spawning on win32
arcanis Mar 23, 2019
bff06d3
More portable path, prevent translating to portable path if already one
Embraser01 Mar 24, 2019
c03bdb4
Some cleanup for PnP hook on Windows
Embraser01 Mar 25, 2019
73b0472
Merge branch 'master' into windows-portable-path
Embraser01 Mar 25, 2019
3ea0c94
Use only portable path in Native resolution
Embraser01 Mar 25, 2019
a25e7fd
Moves the portable path conversion in dedicated wrappers
Mar 25, 2019
9b58424
Makes fakeFs a parameter to instantiate a PnP API
Mar 25, 2019
7c49825
Updates the PnP hook
Mar 25, 2019
4633d4f
Fixes accidental infinite loop
Mar 25, 2019
b9d8553
Updates the checked-in PnP hook
Mar 25, 2019
22edde3
Fixes how the PnP linker interacts with the PnP API on Windows
Mar 25, 2019
2891c1a
Implements a fs layer to convert paths before they reach zipopenfs
Mar 25, 2019
010898a
Adds a few extra conversions
arcanis Mar 25, 2019
a9bf0fe
Updates the checked-in build
Mar 25, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
956 changes: 600 additions & 356 deletions .pnp.js

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
jobs:

# - job: Windows
# pool: 'Hosted VS2017'
- job: Windows
pool:
vmImage: 'vs2017-win2016'

# variables:
# os_name: Windows
variables:
os_name: Windows

# strategy:
# matrix:
# node_8_x:
# node_version: 8.x
# node_10_x:
# node_version: 10.x
strategy:
matrix:
node_8_x:
node_version: 8.x
node_10_x:
node_version: 10.x

# steps:
# - template: scripts/azure-run-tests.yml
steps:
- bash: |
git config core.symlinks true
git reset --hard
- template: scripts/azure-run-tests.yml

- job: Linux
pool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe(`Plug'n'Play`, () => {
},
},
async ({path, run, source}) => {
console.log(path);
await run(`install`);

await expect(
Expand Down
5,910 changes: 3,089 additions & 2,821 deletions packages/berry-cli/bin/berry.js

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions packages/berry-cli/sources/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Configuration} from '@berry/core';
import {xfs} from '@berry/fslib';
import {xfs, NodeFS} from '@berry/fslib';
import {UsageError, Concierge} from '@manaflair/concierge';
import {execFileSync} from 'child_process';
import Joi from 'joi';
Expand All @@ -13,16 +13,18 @@ concierge.topLevel(`[--cwd PATH]`).validate(Joi.object().unknown().keys({
}));

function runBinary(path: string) {
if (path.endsWith(`.js`)) {
execFileSync(process.execPath, [path, ...process.argv.slice(2)], {
const physicalPath = NodeFS.fromPortablePath(path);

if (physicalPath) {
execFileSync(process.execPath, [physicalPath, ...process.argv.slice(2)], {
stdio: `inherit`,
env: {
... process.env,
YARN_IGNORE_PATH: `1`,
}
});
} else {
execFileSync(path, process.argv.slice(2), {
execFileSync(physicalPath, process.argv.slice(2), {
stdio: `inherit`,
env: {
... process.env,
Expand All @@ -33,7 +35,7 @@ function runBinary(path: string) {
}

async function run() {
const configuration = await Configuration.find(process.cwd(), pluginConfiguration);
const configuration = await Configuration.find(NodeFS.toPortablePath(process.cwd()), pluginConfiguration);

const yarnPath = configuration.get(`yarnPath`);
const ignorePath = configuration.get(`ignorePath`);
Expand All @@ -54,7 +56,9 @@ async function run() {
for (const command of plugin.commands || [])
command(concierge, pluginConfiguration);

concierge.runExit(`yarn`, process.argv.slice(2));
concierge.runExit(`yarn`, process.argv.slice(2), {
cwd: NodeFS.toPortablePath(process.cwd())
});
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/berry-core/sources/Cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {NodeFS, ZipFS, xfs} from '@berry/fslib';
import {lock, unlock} from 'lockfile';
import posix from 'path';
import {posix} from 'path';
import {promisify} from 'util';

import {Configuration} from './Configuration';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Cache {

if (expectedChecksum !== null && actualChecksum !== expectedChecksum)
throw new ReportError(MessageName.CACHE_CHECKSUM_MISMATCH, `${structUtils.prettyLocator(this.configuration, locator)} doesn't resolve to an archive that matches the expected checksum`);

return actualChecksum;
};

Expand Down Expand Up @@ -115,7 +115,7 @@ export class Cache {
}

async writeFileIntoCache<T>(file: string, generator: (file: string) => Promise<T>) {
const lock = `${file}.lock`;
const lock = NodeFS.fromPortablePath(`${file}.lock`);

try {
await lockP(lock);
Expand Down
14 changes: 8 additions & 6 deletions packages/berry-core/sources/Configuration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {xfs} from '@berry/fslib';
import {xfs, NodeFS} from '@berry/fslib';
import {parseSyml, stringifySyml} from '@berry/parsers';
import {UsageError} from '@manaflair/concierge';
import chalk from 'chalk';
import {homedir} from 'os';
import {posix} from 'path';
import {posix, win32} from 'path';
import supportsColor from 'supports-color';

import {MultiFetcher} from './MultiFetcher';
Expand Down Expand Up @@ -234,7 +234,7 @@ function parseValue(value: unknown, type: SettingsType, folder: string) {
throw new Error(`Expected value to be a string`);

if (type === SettingsType.ABSOLUTE_PATH) {
return posix.resolve(folder, value);
return posix.resolve(folder, NodeFS.toPortablePath(value));
} else if (type === SettingsType.LOCATOR_LOOSE) {
return structUtils.parseLocator(value, false);
} else if (type === SettingsType.LOCATOR) {
Expand All @@ -246,7 +246,8 @@ function parseValue(value: unknown, type: SettingsType, folder: string) {

function getDefaultGlobalFolder() {
if (process.platform === `win32`) {
return posix.resolve(process.env.LOCALAPPDATA || posix.join(homedir(), 'AppData', 'Local'));
const folder = NodeFS.toPortablePath(process.env.LOCALAPPDATA || win32.join(homedir(), 'AppData', 'Local'));
return posix.resolve(folder);
} else if (process.env.XDG_DATA_HOME) {
return posix.resolve(process.env.XDG_DATA_HOME, 'yarn/modern');
} else {
Expand Down Expand Up @@ -359,8 +360,9 @@ export class Configuration {
if (!Array.isArray(data.plugins))
continue;

for (const pluginPath of data.plugins) {
const {factory, name} = nodeUtils.dynamicRequire(posix.resolve(cwd, pluginPath));
for (const userProvidedPath of data.plugins) {
const pluginPath = posix.resolve(cwd, NodeFS.toPortablePath(userProvidedPath));
const {factory, name} = nodeUtils.dynamicRequire(NodeFS.fromPortablePath(pluginPath));

// Prevent plugin redefinition so that the ones declared deeper in the
// filesystem always have precedence over the ones below.
Expand Down
Loading