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

feat: login and logout commands #118

Merged
merged 48 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5854401
feat: api client logic
alvarosabu Sep 18, 2024
55f33fa
chore: lint fix
alvarosabu Sep 18, 2024
81047b7
feat: netrc credentials logic
alvarosabu Sep 23, 2024
316ce74
chore: remove unused imports on creds tests
alvarosabu Sep 23, 2024
193e1b6
feat: migrate to inquirer/prompts
alvarosabu Sep 23, 2024
303b248
feat: handling path for package.json on tests
alvarosabu Sep 23, 2024
7254e74
feat: check region on login command
alvarosabu Sep 25, 2024
56960ee
feat: login with token and with email
alvarosabu Sep 26, 2024
c908176
feat: improved error handling
alvarosabu Oct 2, 2024
fe4733d
tests: test coverage for login actions
alvarosabu Oct 2, 2024
1cbd2be
test: use correct masktoken fn
alvarosabu Oct 2, 2024
c60f830
tests: removed unused ci option since token acts like one
alvarosabu Oct 2, 2024
9740997
tests: login actions tests
alvarosabu Oct 2, 2024
5755511
tests: login --token tests
alvarosabu Oct 2, 2024
7c83aed
tests: login command tests with different login strategies
alvarosabu Oct 2, 2024
eda9600
tests: coverage
alvarosabu Oct 2, 2024
b883805
chore: minor test fix
alvarosabu Oct 2, 2024
ba7e913
tests: remove commented code
alvarosabu Oct 2, 2024
33ec33a
feat: isAutorized
alvarosabu Oct 2, 2024
9f49385
feat: logout command
alvarosabu Oct 3, 2024
0989948
feat: session credentials handler and updated tests
alvarosabu Oct 3, 2024
32ff580
chore: fix lint
alvarosabu Oct 3, 2024
fb0aa16
chore: improve auth code login message
alvarosabu Oct 4, 2024
54df30e
chore: increase session coverage
alvarosabu Oct 4, 2024
7e448ae
feat: narrow the typesafe of constants
alvarosabu Oct 9, 2024
779d41a
feat(types): improved regions code typing
alvarosabu Oct 9, 2024
aece279
feat: set module resolution to node for tsconfig and add eslint flat …
alvarosabu Oct 10, 2024
d4ecf66
chore: force npm run dev to always stub the build for dev
alvarosabu Oct 10, 2024
64ef7db
chore(tests): type assertion for mocks
alvarosabu Oct 10, 2024
dc677f9
chore: extremely weird choice of identation
alvarosabu Oct 10, 2024
76cba51
feat: improve error handling
alvarosabu Oct 14, 2024
de2f3bb
tests: vi.mocked for the typescript win
alvarosabu Oct 14, 2024
32eb04b
chore: remove unused code for linter
alvarosabu Oct 14, 2024
d786b9c
Merge branch 'next' into feature/login-cmd
alvarosabu Oct 14, 2024
7449f5f
feat: improved error handling part 1, api errors and command errors
alvarosabu Oct 15, 2024
90ccd57
tests: update tests and use msw for api mocks
alvarosabu Oct 16, 2024
2b48927
chore: lint and removing unnecesary else
alvarosabu Oct 16, 2024
4c3582a
chore: lint
alvarosabu Oct 16, 2024
658202e
feat: refactor removeNetrcEntry to make machineName required
alvarosabu Oct 16, 2024
c1f0eef
feat: change order of `removeNetrcEntry` params
alvarosabu Oct 16, 2024
f7a4910
feat: remove casting in favor of runtime checking
alvarosabu Oct 16, 2024
0201fad
feat: verbose mode
alvarosabu Oct 16, 2024
432b641
feat: added correct flow when user doesnt require otp
alvarosabu Oct 29, 2024
72d788f
feat: handle user cancelation error when inquirer is prompting
alvarosabu Oct 29, 2024
1860665
feat: remove all netrc entries on logout
alvarosabu Oct 29, 2024
c63d382
feat: added http response code to api error verbose mode
alvarosabu Oct 29, 2024
3235497
feat: remove unnecesary netrc handling warnings
alvarosabu Oct 29, 2024
c8472d0
feat: improved error handling for file permissions
alvarosabu Oct 29, 2024
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
10 changes: 5 additions & 5 deletions .github/.dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: npm
directory: /
schedule:
interval: "monthly"
interval: monthly
allow:
- dependency-name: "@storyblok/region-helper"
- dependency-name: '@storyblok/region-helper'
reviewers:
- "storyblok/plugins-team"
- storyblok/plugins-team
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ assignees: ''

---


**Current behavior:**
<!-- Describe how the bug manifests. -->

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- run: pnpx pkg-pr-new publish --compact --pnpm
- run: pnpx pkg-pr-new publish --compact --pnpm
37 changes: 21 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,36 @@
{
"type": "node",
"request": "launch",
"name": "Debug Jest Tests",
"runtimeArgs": [
"--experimental-vm-modules"
],
"args": [
"--silent",
"--runInBand"
],
"name": "Debug Vitest Tests",
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"args": ["run"],
"autoAttachChildProcesses": true,
"smartStep": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"windows": {
"program": "${workspaceFolder}\\node_modules\\jest\\bin\\jest.js"
}
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
"name": "Debug pull-components",
"program": "${workspaceFolder}/dist/cli.mjs",
"args": ["push-components", "components.295017.json", "--space", "295018"],
"name": "Debug login",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["login"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"type": "node",
"request": "launch",
"name": "Debug logout",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["logout"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
}
45 changes: 41 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
"eslint.format.enable": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"editor.defaultFormatter": "esbenp.prettier-vscode"

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "format/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"yml"
]
}
6 changes: 6 additions & 0 deletions __mocks__/fs.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// we can also use `import`, but then
// every export should be explicitly defined

const { fs } = require('memfs')

module.exports = fs
6 changes: 6 additions & 0 deletions __mocks__/fs/promises.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// we can also use `import`, but then
// every export should be explicitly defined

const { fs } = require('memfs')

module.exports = fs.promises
4 changes: 4 additions & 0 deletions __mocks__/test.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
machine api.storyblok.com
login julio.iglesias@storyblok.com
password my_access_token
region eu
5 changes: 3 additions & 2 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineBuildConfig } from 'unbuild';
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
declaration: true,
entries: ['./src/index'],
externals: ['consola', 'pathe'],
});
failOnWarn: false,
})
8 changes: 3 additions & 5 deletions eslint.config.js → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { storyblokLintConfig } from '@storyblok/eslint-config'

export default storyblokLintConfig({
rules: [
{
'no-console': 'off'
}
]
rules: {
'no-console': 'off',
},
})
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "storyblok",
"type": "module",
"version": "0.0.0",
"packageManager": "pnpm@9.9.0",
"description": "Storyblok CLI",
Expand All @@ -26,23 +25,28 @@
"scripts": {
"build": "unbuild",
"build:stub": "unbuild --stub",
"dev": "node dist/index.mjs",
"dev": "pnpm run build:stub && STUB=true node dist/index.mjs",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest"

"test": "vitest",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@inquirer/prompts": "^6.0.1",
"chalk": "^5.3.0",
"commander": "^12.1.0",
"consola": "^3.2.3",
"inquirer": "^10.2.2"
"dotenv": "^16.4.5",
"ofetch": "^1.4.0",
"storyblok-js-client": "^6.9.2"
},
"devDependencies": {
"@storyblok/eslint-config": "^0.2.0",
"@types/inquirer": "^9.0.7",
"@types/node": "^22.5.4",
"@vitest/coverage-v8": "^2.1.1",
"eslint": "^9.10.0",
"memfs": "^4.11.2",
"pathe": "^1.1.2",
"typescript": "^5.6.2",
"unbuild": "^2.0.0",
Expand Down
Loading
Loading