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

Uses js-yaml for parsing #183

Merged
merged 11 commits into from May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .pnp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .yarnrc
@@ -1,12 +1,16 @@
## General settings

init-scope: berry

npm-publish-access: public

yarn-path: scripts/run-yarn.js

## List of plugins enabled in the current repository

plugins:
- scripts/plugin-exec.js
- scripts/plugin-stage.js
- scripts/plugin-typescript.js
- scripts/plugin-version.js
- scripts/plugin-workspace-tools.js

yarn-path: ./scripts/run-yarn.js
18 changes: 9 additions & 9 deletions packages/acceptance-tests/pkg-tests-specs/sources/auth.test.js
Expand Up @@ -43,7 +43,7 @@ describe(`Auth tests`, () => {
dependencies: {[`no-deps`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAlwaysAuth true\n`);
await writeFile(`${path}/.yarnrc`, `npmAlwaysAuth: true\n`);

await expect(run(`install`)).rejects.toThrowError(/No authentication configured for request/);
},
Expand All @@ -57,7 +57,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthToken "${AUTH_TOKEN}"\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthToken: "${AUTH_TOKEN}"\n`);

// Rejected by 401 error from registry so no validation on the error message
await expect(run(`install`)).rejects.toThrow();
Expand All @@ -72,7 +72,7 @@ describe(`Auth tests`, () => {
dependencies: {[`@private/package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthToken "${AUTH_TOKEN}"\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthToken: "${AUTH_TOKEN}"\n`);

await run(`install`);

Expand All @@ -91,7 +91,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthToken "${AUTH_TOKEN}"\nnpmAlwaysAuth true\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthToken: "${AUTH_TOKEN}"\nnpmAlwaysAuth: true\n`);

await run(`install`);

Expand All @@ -110,7 +110,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthIdent "${AUTH_IDENT}"\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthIdent: "${AUTH_IDENT}"\n`);

// Rejected by 401 error from registry so no validation on the error message
await expect(run(`install`)).rejects.toThrow();
Expand All @@ -125,7 +125,7 @@ describe(`Auth tests`, () => {
dependencies: {[`@private/package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthIdent "${AUTH_IDENT}"\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthIdent: "${AUTH_IDENT}"\n`);

await run(`install`);

Expand All @@ -144,7 +144,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthIdent "${AUTH_IDENT}"\nnpmAlwaysAuth true\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthIdent: "${AUTH_IDENT}"\nnpmAlwaysAuth: true\n`);

await run(`install`);

Expand All @@ -163,7 +163,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthToken "${INVALID_AUTH_TOKEN}"\nnpmAlwaysAuth true\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthToken: "${INVALID_AUTH_TOKEN}"\nnpmAlwaysAuth: true\n`);

await expect(run(`install`)).rejects.toThrow();
},
Expand All @@ -177,7 +177,7 @@ describe(`Auth tests`, () => {
dependencies: {[`private-package`]: `1.0.0`},
},
async ({path, run, source}) => {
await writeFile(`${path}/.yarnrc`, `npmAuthIdent "${INVALID_AUTH_IDENT}"\nnpmAlwaysAuth true\n`);
await writeFile(`${path}/.yarnrc`, `npmAuthIdent: "${INVALID_AUTH_IDENT}"\nnpmAlwaysAuth: true\n`);

await expect(run(`install`)).rejects.toThrow();
},
Expand Down
Expand Up @@ -14,22 +14,22 @@ const environments = {
// Nothing to do
},
[`folder with rcfile`]: async ({path}) => {
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope berry-test\n`);
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope: berry-test\n`);
},
[`folder with rcfile without trailing newline`]: async ({path}) => {
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope berry-test`);
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope: berry-test`);
},
[`folder with rcfile and rc in parent`]: async ({path}) => {
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope berry-test\n`);
await writeFile(`${path}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope value-to-override\nlastUpdateCheck 1555784893958\n`);
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope: berry-test\n`);
await writeFile(`${path}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope: value-to-override\nlast-update-check: 1555784893958\n`);
},
[`folder with rcfile and rc in ancestor parent`]: async ({path}) => {
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope berry-test\n`);
await writeFile(`${path}/${RC_FILENAME}`, `init-scope value-to-override\nlastUpdateCheck 1555784893958\n`);
await writeFile(`${path}/${SUBFOLDER}/${SUBFOLDER}/${RC_FILENAME}`, `init-scope: berry-test\n`);
await writeFile(`${path}/${RC_FILENAME}`, `init-scope: value-to-override\nlast-update-check: 1555784893958\n`);
},
[`folder with rcfile and rc in home folder`]: async ({path, homePath}) => {
await writeFile(`${homePath}/${RC_FILENAME}`, `init-scope value-to-override\ndefaultLanguageName python\n`);
await writeFile(`${path}/${RC_FILENAME}`, `init-scope berry-test\nlastUpdateCheck 1555784893958\n`);
await writeFile(`${homePath}/${RC_FILENAME}`, `init-scope: value-to-override\ndefault-language-name: python\n`);
await writeFile(`${path}/${RC_FILENAME}`, `init-scope: berry-test\nlast-update-check: 1555784893958\n`);
},
};

Expand Down
@@ -0,0 +1,71 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Commands npm login it should login a user with OTP setup 1`] = `
"npmAuthToken: 686159dc-64b3-413e-a244-2de2b8d1c36f
"
`;

exports[`Commands npm login it should login a user with OTP setup 2`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: Successfully logged in
➤ YN0000: Done
",
}
`;

exports[`Commands npm login it should login a user with OTP to a specific scope 1`] = `
"init-scope: berry-test

npmScopes:
testScope:
npmAuthToken: 686159dc-64b3-413e-a244-2de2b8d1c36f
npmRegistryServer: \\"http://yarn.test.registry\\"
"
`;

exports[`Commands npm login it should login a user with OTP to a specific scope 2`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: Successfully logged in
➤ YN0000: Done
",
}
`;

exports[`Commands npm login it should login a user with no OTP setup 1`] = `
"npmAuthToken: 316158de-64b3-413e-a244-2de2b8d1c80f
"
`;

exports[`Commands npm login it should login a user with no OTP setup 2`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: Successfully logged in
➤ YN0000: Done
",
}
`;

exports[`Commands npm login it should login a user with no OTP setup to a specific scope 1`] = `
"init-scope: berry-test

npmScopes:
testScope:
npmAuthToken: 316158de-64b3-413e-a244-2de2b8d1c80f
npmRegistryServer: \\"http://yarn.test.registry\\"
"
`;

exports[`Commands npm login it should login a user with no OTP setup to a specific scope 2`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: Successfully logged in
➤ YN0000: Done
",
}
`;
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Commands npm whoami it should print the npm registry username for a given scope 1`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: username
➤ YN0000: Done
",
}
`;

exports[`Commands npm whoami it should print the npm registry username when config has a valid npmAuthIdent 1`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: username
➤ YN0000: Done
",
}
`;

exports[`Commands npm whoami it should print the npm registry username when config has a valid npmAuthToken 1`] = `
Object {
"code": 0,
"stderr": "",
"stdout": "➤ YN0000: username
➤ YN0000: Done
",
}
`;