Skip to content

Commit

Permalink
docs: move website to svgr repo (gregberge#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge authored Dec 12, 2018
1 parent 36a43e2 commit 8d4dfa9
Show file tree
Hide file tree
Showing 59 changed files with 16,694 additions and 1,084 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ __fixtures__/
__fixtures_build__/
coverage/
examples/
svgr.now.sh/
svgr.now.sh/
/website/.cache/
/website/public/
19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"root": true,
"parser": "babel-eslint",
"extends": ["airbnb", "prettier", "prettier/react"],
"env": {
"jest": true
},
"rules": {
"no-plusplus": "off",
"no-shadow": "off",
"class-methods-use-this": "off",
"no-param-reassign": "off",
"no-use-before-define": "off",
"import/prefer-default-export": "off",
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
"react/jsx-wrap-multilines": "off",
"react/no-unused-state": "off",
"react/destructuring-assignment": "off",
"react/prop-types": "off",
"react/sort-comp": "off"
}
}
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ CHANGELOG.md
package.json
lerna.json
lib/
.next/
.next/
/website/.cache/
/website/public/
6 changes: 3 additions & 3 deletions BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ SVGR is an MIT-licensed open source project. Even if it has been created at Smoo

## Gold Sponsors

Gold Sponsors are those who have pledged $200/month and more to SVGR.
Gold Sponsors are those who have pledged \$200/month and more to SVGR.

[![gold-sponsors](https://opencollective.com/svgr/tiers/gold-sponsors.svg?avatarHeight=120&width=600)](https://opencollective.com/svgr/order/6010)

## Silver Sponsors

Silver Sponsors are those who have pledged $100/month to $200/month to SVGR.
Silver Sponsors are those who have pledged $100/month to$200/month to SVGR.

[![silver-sponsors](https://opencollective.com/svgr/tiers/silver-sponsors.svg?avatarHeight=120&width=600)](https://opencollective.com/svgr/order/6008)

## Bronze Sponsors

Bronze Sponsors are those who have pledged $50/month to $100/month to SVGR.
Bronze Sponsors are those who have pledged $50/month to$100/month to SVGR.

[![bronze-sponsors](https://opencollective.com/svgr/tiers/bronze-sponsors.svg?avatarHeight=80&width=600)](https://opencollective.com/svgr/order/6009)

Expand Down
11 changes: 11 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Global settings applied to the whole site.
#
# “publish” is the directory to publish (relative to root of your repo),
# “command” is your build command,
# “base” is directory to change to before starting build. if you set base:
# that is where we will look for package.json/.nvmrc/etc not repo root!

[build]
base = "website"
publish = "website/public"
command = "yarn build:pp"
1 change: 1 addition & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": 1,
"name": "svgr",
"alias": "svgr"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
"codecov": "^3.1.0",
"conventional-github-releaser": "^3.1.2",
"eslint": "^5.9.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"jest": "^23.6.0",
"lerna": "^3.4.3",
"react": "^16.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-remove-jsx-attribute/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const removeJSXAttribute = (api, opts) => ({
if (!opts.elements.includes(path.node.name.name)) return

path.get('attributes').forEach(attribute => {
const nodeName = attribute.node.name;
const nodeName = attribute.node.name
if (nodeName && opts.attributes.includes(nodeName.name)) {
attribute.remove()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/dirCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function dirCommand(
if (!isCompilable(relative)) return false
relative = rename(relative, ext, filenameCase)

const dest = path.resolve(program.outDir, relative);
const dest = path.resolve(program.outDir, relative)
const code = await convertFile(src, options)
outputFileSync(dest, code)
process.stdout.write(`${src} -> ${dest}\n`)
Expand Down
194 changes: 75 additions & 119 deletions packages/cli/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,105 +16,69 @@ describe('cli', () => {
return stdout
}

it(
'should work with a simple file',
async () => {
const result = await cli('__fixtures__/simple/file.svg')
expect(result).toMatchSnapshot()
},
10000,
)

it(
'should not work with a directory without --out-dir option',
async () => {
expect.assertions(1)
try {
await cli('__fixtures__/nesting')
} catch (error) {
expect(error.message).toMatch(
'Directory are not supported without `--out-dir` option instead',
)
}
},
10000,
)

it(
'should not work with several files without destination',
async () => {
expect.assertions(1)
try {
await cli('__fixtures__/simple/file.svg __fixtures__/nesting/one.svg')
} catch (error) {
expect(error.message).toMatch(
'Please specify only one filename or use `--out-dir` option',
)
}
},
10000,
)

it(
'should work with stdin',
async () => {
const result = await cli('< __fixtures__/simple/file.svg')
expect(result).toMatchSnapshot()
},
10000,
)

it(
'should transform a whole directory',
async () => {
await cli('--out-dir __fixtures_build__/whole __fixtures__')
},
10000,
)

it(
'should support --prettier-config as json',
async () => {
const result = await cli(
`--prettier-config '{"tabWidth": 5}' __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
},
10000,
)

it(
'should support --prettier-config as file',
async () => {
const result = await cli(
`--prettier-config __fixtures__/withPrettierRc/.prettierrc __fixtures__/simple/file.svg`,
it('should work with a simple file', async () => {
const result = await cli('__fixtures__/simple/file.svg')
expect(result).toMatchSnapshot()
}, 10000)

it('should not work with a directory without --out-dir option', async () => {
expect.assertions(1)
try {
await cli('__fixtures__/nesting')
} catch (error) {
expect(error.message).toMatch(
'Directory are not supported without `--out-dir` option instead',
)
expect(result).toMatchSnapshot()
},
10000,
)

it(
'should support --svgo-config as json',
async () => {
const result = await cli(
`--svgo-config '{"plugins": [{"removeTitle": false}]}' __fixtures__/simple/file.svg`,
}
}, 10000)

it('should not work with several files without destination', async () => {
expect.assertions(1)
try {
await cli('__fixtures__/simple/file.svg __fixtures__/nesting/one.svg')
} catch (error) {
expect(error.message).toMatch(
'Please specify only one filename or use `--out-dir` option',
)
expect(result).toMatchSnapshot()
},
10000,
)

it(
'should support --svgo-config as file',
async () => {
const result = await cli(
`--svgo-config __fixtures__/withSvgoYml/.svgo.json __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
},
10000,
)
}
}, 10000)

it('should work with stdin', async () => {
const result = await cli('< __fixtures__/simple/file.svg')
expect(result).toMatchSnapshot()
}, 10000)

it('should transform a whole directory', async () => {
await cli('--out-dir __fixtures_build__/whole __fixtures__')
}, 10000)

it('should support --prettier-config as json', async () => {
const result = await cli(
`--prettier-config '{"tabWidth": 5}' __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
}, 10000)

it('should support --prettier-config as file', async () => {
const result = await cli(
`--prettier-config __fixtures__/withPrettierRc/.prettierrc __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
}, 10000)

it('should support --svgo-config as json', async () => {
const result = await cli(
`--svgo-config '{"plugins": [{"removeTitle": false}]}' __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
}, 10000)

it('should support --svgo-config as file', async () => {
const result = await cli(
`--svgo-config __fixtures__/withSvgoYml/.svgo.json __fixtures__/simple/file.svg`,
)
expect(result).toMatchSnapshot()
}, 10000)

it.each([
['--no-dimensions'],
Expand Down Expand Up @@ -157,26 +121,18 @@ describe('cli', () => {
10000,
)

it(
'should support custom file extension',
async () => {
const inDir = '__fixtures__/simple'
const outDir = '__fixtures_build__/ext'
await del(outDir)
await cli(`--ext=ts ${inDir} --out-dir=${outDir}`)
expect(await readdir(outDir)).toMatchSnapshot()
},
10000,
)

it(
'should not override config with cli defaults',
async () => {
const result = await cli(
'__fixtures__/simple/file.svg --config-file=__fixtures__/overrides.config.js',
)
expect(result).toMatchSnapshot()
},
10000,
)
it('should support custom file extension', async () => {
const inDir = '__fixtures__/simple'
const outDir = '__fixtures_build__/ext'
await del(outDir)
await cli(`--ext=ts ${inDir} --out-dir=${outDir}`)
expect(await readdir(outDir)).toMatchSnapshot()
}, 10000)

it('should not override config with cli defaults', async () => {
const result = await cli(
'__fixtures__/simple/file.svg --config-file=__fixtures__/overrides.config.js',
)
expect(result).toMatchSnapshot()
}, 10000)
})
Loading

0 comments on commit 8d4dfa9

Please sign in to comment.