-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to use SvelteKit package command
This allows importing the library without having to use TypeScript preprocessors which is the recommended way sveltejs/component-template#29
- Loading branch information
1 parent
02d14e0
commit dde1f93
Showing
27 changed files
with
171 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ coverage | |
# production | ||
build | ||
dist | ||
package | ||
|
||
# misc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
import { promisify } from 'util' | ||
import { exec as rawExec } from 'child_process' | ||
import { promises as fs } from 'fs' | ||
import path from 'path' | ||
|
||
const exec = promisify(rawExec) | ||
|
||
async function readJson(path) { | ||
const pkg = await fs.readFile(path, 'utf-8').catch(err => console.error(err)) | ||
if (!pkg) return undefined | ||
return JSON.parse(pkg) | ||
} | ||
|
||
async function cleanCurrentExports() { | ||
const pkg = await readJson('./package.json') | ||
pkg.exports = {} | ||
await fs.writeFile('./package.json', JSON.stringify(pkg, null, 2)) | ||
} | ||
|
||
async function writePackageExports() { | ||
const oldPkg = await readJson('./package.json') | ||
const newPkg = await readJson('./package/package.json') | ||
oldPkg.exports = Object.keys(newPkg.exports).reduce((acc, key) => { | ||
const newPath = path.join('./package', newPkg.exports[key]) | ||
acc[key] = `./${newPath}` | ||
return acc | ||
}, {}) | ||
await fs.writeFile('./package.json', JSON.stringify(oldPkg, null, 2)) | ||
} | ||
|
||
async function build() { | ||
await cleanCurrentExports() | ||
await exec('yarn build:pkg') | ||
await exec('yarn build:dist') | ||
await exec('rm ./package/.npmignore') | ||
await writePackageExports() | ||
await exec('rm ./package/package.json') | ||
} | ||
|
||
build() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta | ||
name="description" | ||
content="svelte-tree-view is a Svelte library to render Javascript objects in a tree layout" | ||
/> | ||
<title>svelte-tree-view</title> | ||
|
||
<script> | ||
try { | ||
if (!('theme' in localStorage)) { | ||
localStorage.theme = window.matchMedia('(prefers-color-scheme: dark)').matches | ||
? 'dark' | ||
: 'light' | ||
} | ||
|
||
document.querySelector('html').classList.add(localStorage.theme) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
</script> | ||
|
||
%svelte.head% | ||
</head> | ||
|
||
<body> | ||
<div id="svelte">%svelte.body%</div> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
const autoPreprocess = require('svelte-preprocess') | ||
import autoPreprocess from 'svelte-preprocess' | ||
|
||
const preprocessOptions = { | ||
scss: {} | ||
} | ||
|
||
module.exports = { | ||
export default { | ||
preprocess: autoPreprocess(preprocessOptions), | ||
preprocessOptions | ||
preprocessOptions, | ||
kit: { | ||
package: { | ||
exports: { | ||
include: ['**'], | ||
exclude: ['package.json', 'types.ts'] | ||
}, | ||
files: { | ||
include: ['**'], | ||
exclude: ['__tests__/**/*'] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1462,6 +1462,16 @@ | |
sade "^1.7.4" | ||
vite "^2.5.7" | ||
|
||
"@sveltejs/kit@^1.0.0-next.168": | ||
version "1.0.0-next.171" | ||
resolved "https://registry.yarnpkg.com/@sveltejs/kit/-/kit-1.0.0-next.171.tgz#7c0843cb65d6697d48a87633611e1d407858cf91" | ||
integrity sha512-lDdEc6eVc8ILuQavHw/HKK7rQs3LMPp1gxieoChvSJGix/GGEaxaOQlUH0JyoLridqzQo39z6XM0giwWLQtGfA== | ||
dependencies: | ||
"@sveltejs/vite-plugin-svelte" "^1.0.0-next.24" | ||
cheap-watch "^1.0.4" | ||
sade "^1.7.4" | ||
vite "^2.5.7" | ||
|
||
"@sveltejs/vite-plugin-svelte@^1.0.0-next.24": | ||
version "1.0.0-next.24" | ||
resolved "https://registry.yarnpkg.com/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-1.0.0-next.24.tgz#55033c27b5f428e804ff64f410a640baacff0333" | ||
|
@@ -2484,6 +2494,11 @@ cheap-watch@^1.0.3: | |
resolved "https://registry.yarnpkg.com/cheap-watch/-/cheap-watch-1.0.3.tgz#3c4265718bcf8f1ae08f5e450f9f4693432e028e" | ||
integrity sha512-xC5CruMhLzjPwJ5ecUxGu1uGmwJQykUhqd2QrCrYbwvsFYdRyviu6jG9+pccwDXJR/OpmOTOJ9yLFunVgQu9wg== | ||
|
||
cheap-watch@^1.0.4: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/cheap-watch/-/cheap-watch-1.0.4.tgz#0bcb4a3a8fbd9d5327936493f6b56baa668d8fef" | ||
integrity sha512-QR/9FrtRL5fjfUJBhAKCdi0lSRQ3rVRRum3GF9wDKp2TJbEIMGhUEr2yU8lORzm9Isdjx7/k9S0DFDx+z5VGtw== | ||
|
||
check-more-types@^2.24.0: | ||
version "2.24.0" | ||
resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600" | ||
|
@@ -2911,6 +2926,11 @@ decode-uri-component@^0.2.0: | |
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" | ||
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= | ||
|
||
dedent-js@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/dedent-js/-/dedent-js-1.0.1.tgz#bee5fb7c9e727d85dffa24590d10ec1ab1255305" | ||
integrity sha1-vuX7fJ5yfYXf+iRZDRDsGrElUwU= | ||
|
||
dedent@^0.7.0: | ||
version "0.7.0" | ||
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" | ||
|
@@ -4984,6 +5004,13 @@ log-update@^4.0.0: | |
slice-ansi "^4.0.0" | ||
wrap-ansi "^6.2.0" | ||
|
||
lower-case@^2.0.2: | ||
version "2.0.2" | ||
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" | ||
integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== | ||
dependencies: | ||
tslib "^2.0.3" | ||
|
||
lru-cache@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" | ||
|
@@ -5171,6 +5198,14 @@ natural-compare@^1.4.0: | |
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" | ||
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= | ||
|
||
no-case@^3.0.4: | ||
version "3.0.4" | ||
resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" | ||
integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== | ||
dependencies: | ||
lower-case "^2.0.2" | ||
tslib "^2.0.3" | ||
|
||
node-emoji@^1.11.0: | ||
version "1.11.0" | ||
resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.11.0.tgz#69a0150e6946e2f115e9d7ea4df7971e2628301c" | ||
|
@@ -5473,6 +5508,14 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" | ||
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== | ||
|
||
pascal-case@^3.1.1: | ||
version "3.1.2" | ||
resolved "https://registry.yarnpkg.com/pascal-case/-/pascal-case-3.1.2.tgz#b48e0ef2b98e205e7c1dae747d0b1508237660eb" | ||
integrity sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g== | ||
dependencies: | ||
no-case "^3.0.4" | ||
tslib "^2.0.3" | ||
|
||
path-exists@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" | ||
|
@@ -6548,6 +6591,14 @@ svelte-preprocess@^4.0.0, svelte-preprocess@^4.8.0: | |
detect-indent "^6.0.0" | ||
strip-indent "^3.0.0" | ||
|
||
svelte2tsx@^0.4.6: | ||
version "0.4.6" | ||
resolved "https://registry.yarnpkg.com/svelte2tsx/-/svelte2tsx-0.4.6.tgz#3435064962c910c0a075b4a1c04e91eaf568f5e5" | ||
integrity sha512-flljgh/MbJDijo6Z1HhCfyzdRgn1Nd7QTuuxk9Oq5CzyBXZl/NJYh4otZZwUHnx5poy8k7Oxr2CBE3IBh89tmQ== | ||
dependencies: | ||
dedent-js "^1.0.1" | ||
pascal-case "^3.1.1" | ||
|
||
svelte@^3.42.4: | ||
version "3.42.4" | ||
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.42.4.tgz#838ed98fa7b26fc5fffe4df0d7ba345f1c54cf4f" | ||
|
@@ -6773,7 +6824,7 @@ tslib@^1.8.1, tslib@^1.9.0: | |
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" | ||
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== | ||
|
||
tslib@^2.3.1: | ||
tslib@^2.0.3, tslib@^2.3.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" | ||
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== | ||
|