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

Towards yarn v3 (berry) #29

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3e64b5e
Towards yarn v2 (berry)
kachkaev Oct 17, 2020
04a26de
Change yarn flag
kachkaev Oct 17, 2020
f7e2650
Fix prettier and run-if-changed command
kachkaev Oct 18, 2020
d26e521
Use new eslint rules
kachkaev Oct 18, 2020
3ead67c
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Oct 18, 2020
a8f9fa0
Tweak markdownlint config
kachkaev Oct 18, 2020
88f0051
Bump pnpfied version of typescript
kachkaev Oct 18, 2020
4f298b1
Bring back Prettier plugins
kachkaev Oct 19, 2020
d2f5380
Bump dependencies
kachkaev Nov 22, 2020
0bd478f
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Nov 28, 2020
a07c57d
Change yarn path
kachkaev Nov 28, 2020
545e824
Merge branch 'main' into yarn-berry
kachkaev Dec 19, 2020
e39d0d9
Try removing dependenciesMeta
kachkaev Dec 26, 2020
4b8c84a
Try removing dependenciesMeta
kachkaev Dec 26, 2020
8ad5913
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Jan 16, 2021
39aadac
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Jan 16, 2021
16e721d
Merge branch 'main' into yarn-berry
kachkaev Apr 13, 2021
e0a9eae
Merge branch 'main' into yarn-berry, upgrade yarn to v3.0.0
kachkaev Aug 7, 2021
02e5ef3
Add eslint-config-next
kachkaev Aug 7, 2021
53ae480
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Sep 23, 2021
7eb5b81
Upgrade yarn to 3.0.2
kachkaev Sep 23, 2021
497f8e6
Update husky config
kachkaev Sep 23, 2021
58b5600
Merge remote-tracking branch 'origin/main' into yarn-berry
kachkaev Sep 24, 2021
3ce8297
Run "yarn fix:prettier"
kachkaev Sep 24, 2021
a8cc632
Update VSCode SDKs (yarn dlx @yarnpkg/sdks vscode)
kachkaev Sep 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ LICENSE

## same as in .gitignore
# dependencies
node_modules
.pnp
.pnp.js
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# testing
/coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: 12

- name: Install dependencies
run: yarn install --frozen-lockfile
run: yarn install --immutable

- name: Lint
run: yarn lint
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# dependencies
node_modules
.pnp
.pnp.js
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# testing
/coverage
Expand Down
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./node_modules/@kachkaev/markdownlint-config/index.json",
"extends": "@kachkaev/markdownlint-config",
"first-line-heading": false,
"no-inline-html": false
}
9 changes: 6 additions & 3 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ LICENSE

## same as in .gitignore
# dependencies
node_modules
.pnp
.pnp.js
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# testing
/coverage
Expand Down
9 changes: 6 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ LICENSE

## same as in .gitignore
# dependencies
node_modules
.pnp
.pnp.js
.yarn/*
!.yarn/releases
!.yarn/plugins
Comment on lines +16 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!.yarn/releases
!.yarn/plugins

You probably don't want prettier to touch these files

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are right! Same for ESLint and Markdownlint. What is interesting though is that I just ran yarn fix:prettier and did not notice any .yarn/* paths in stdout. I guess that something in my approach to config files ends up excluding all folders starting with the dot by default. For that reason, I had to add !/.github/ a while ago (see above) — otherwise the yamls were not formatted.

I’ll see what's best: to keep things as is or to ‘break the symmetry’ between the ignore files. Gonna switch to work work till the next weekend 🙂

!.yarn/sdks
!.yarn/versions
.pnp.*

# testing
/coverage
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@kachkaev/prettier-config");
1 change: 0 additions & 1 deletion .prettierrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
55 changes: 55 additions & 0 deletions .yarn/releases/yarn-berry.cjs

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .yarn/sdks/eslint/bin/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/bin/eslint.js
require(absPnpApiPath).setup();
}
}

// Defer to the real eslint/bin/eslint.js your application uses
module.exports = absRequire(`eslint/bin/eslint.js`);
20 changes: 20 additions & 0 deletions .yarn/sdks/eslint/lib/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/lib/api.js
require(absPnpApiPath).setup();
}
}

// Defer to the real eslint/lib/api.js your application uses
module.exports = absRequire(`eslint/lib/api.js`);
6 changes: 6 additions & 0 deletions .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "eslint",
"version": "7.11.0-pnpify",
"main": "./lib/api.js",
"type": "commonjs"
}
5 changes: 5 additions & 0 deletions .yarn/sdks/integrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is automatically generated by PnPify.
# Manual changes will be lost!

integrations:
- vscode
20 changes: 20 additions & 0 deletions .yarn/sdks/prettier/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/index.js
require(absPnpApiPath).setup();
}
}

// Defer to the real prettier/index.js your application uses
module.exports = absRequire(`prettier/index.js`);
6 changes: 6 additions & 0 deletions .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "prettier",
"version": "2.1.2-pnpify",
"main": "./index.js",
"type": "commonjs"
}
20 changes: 20 additions & 0 deletions .yarn/sdks/typescript/bin/tsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsc
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/bin/tsc your application uses
module.exports = absRequire(`typescript/bin/tsc`);
20 changes: 20 additions & 0 deletions .yarn/sdks/typescript/bin/tsserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/bin/tsserver
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/bin/tsserver your application uses
module.exports = absRequire(`typescript/bin/tsserver`);
20 changes: 20 additions & 0 deletions .yarn/sdks/typescript/lib/tsc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsc.js
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/lib/tsc.js your application uses
module.exports = absRequire(`typescript/lib/tsc.js`);
77 changes: 77 additions & 0 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

const moduleWrapper = tsserver => {
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
// doesn't understand. This layer makes sure to remove the protocol
// before forwarding it to TS, and to add it back on all returned paths.

const {isAbsolute} = require(`path`);

const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let isVSCode = false;

return Object.assign(Session.prototype, {
onMessage(/** @type {string} */ message) {
const parsedMessage = JSON.parse(message)

if (
parsedMessage != null &&
typeof parsedMessage === 'object' &&
parsedMessage.arguments &&
parsedMessage.arguments.hostInfo === 'vscode'
) {
isVSCode = true;
}

return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
return typeof value === 'string' ? removeZipPrefix(value) : value;
}));
},

send(/** @type {any} */ msg) {
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
return typeof value === 'string' ? addZipPrefix(value) : value;
})));
}
});

function addZipPrefix(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || str.match(/\$\$virtual\//))) {
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
// https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
return `${isVSCode ? '^' : ''}zip:${str.replace(/^\/?/, `/`)}`;
} else {
return str;
}
}

function removeZipPrefix(str) {
return process.platform === 'win32'
? str.replace(/^\^?zip:\//, ``)
: str.replace(/^\^?zip:/, ``);
}
};

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsserver.js
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/lib/tsserver.js your application uses
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
20 changes: 20 additions & 0 deletions .yarn/sdks/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);

const relPnpApiPath = "../../../../.pnp.js";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/typescript.js
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/lib/typescript.js your application uses
module.exports = absRequire(`typescript/lib/typescript.js`);
6 changes: 6 additions & 0 deletions .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "typescript",
"version": "4.0.3-pnpify",
"main": "./lib/typescript.js",
"type": "commonjs"
}
8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
yarnPath: ".yarn/releases/yarn-berry.cjs"
packageExtensions:
styled-components@*:
dependencies:
react-is: "*"
eslint-module-utils@*:
dependencies:
eslint-import-resolver-node: "*"
4 changes: 1 addition & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"name": "Alexander Kachkaev",
"email": "alexander@kachkaev.ru"
},
"bin": {
"njt": "cli.js"
},
"bin": "cli.js",
"scripts": {
"prepublishOnly": "yarn ncp ../README.md README.md"
},
Expand Down