sv 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +20 -128
  3. package/dist/bin.js +13085 -0
  4. package/dist/bin.js.map +1 -0
  5. package/dist/index-CfDBZLMZ.js +137 -0
  6. package/dist/index-CfDBZLMZ.js.map +1 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +5 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/shared.json +138 -0
  11. package/dist/templates/demo/assets/DOT-gitignore +21 -0
  12. package/dist/templates/demo/assets/DOT-npmrc +1 -0
  13. package/dist/templates/demo/assets/src/app.css +107 -0
  14. package/dist/templates/demo/assets/src/app.html +12 -0
  15. package/dist/templates/demo/assets/src/lib/images/github.svg +16 -0
  16. package/dist/templates/demo/assets/src/lib/images/svelte-logo.svg +1 -0
  17. package/dist/templates/demo/assets/src/lib/images/svelte-welcome.png +0 -0
  18. package/dist/templates/demo/assets/src/lib/images/svelte-welcome.webp +0 -0
  19. package/dist/templates/demo/assets/static/favicon.png +0 -0
  20. package/dist/templates/demo/assets/static/robots.txt +3 -0
  21. package/dist/templates/demo/files.types=checkjs.json +62 -0
  22. package/dist/templates/demo/files.types=none.json +58 -0
  23. package/dist/templates/demo/files.types=typescript.json +62 -0
  24. package/dist/templates/demo/meta.json +4 -0
  25. package/dist/templates/demo/package.json +19 -0
  26. package/dist/templates/skeleton/assets/DOT-gitignore +21 -0
  27. package/dist/templates/skeleton/assets/DOT-npmrc +1 -0
  28. package/dist/templates/skeleton/assets/src/app.html +12 -0
  29. package/dist/templates/skeleton/assets/static/favicon.png +0 -0
  30. package/dist/templates/skeleton/files.types=checkjs.json +14 -0
  31. package/dist/templates/skeleton/files.types=none.json +10 -0
  32. package/dist/templates/skeleton/files.types=typescript.json +14 -0
  33. package/dist/templates/skeleton/meta.json +4 -0
  34. package/dist/templates/skeleton/package.json +18 -0
  35. package/dist/templates/skeletonlib/assets/DOT-gitignore +22 -0
  36. package/dist/templates/skeletonlib/assets/DOT-npmrc +1 -0
  37. package/dist/templates/skeletonlib/assets/src/app.html +12 -0
  38. package/dist/templates/skeletonlib/assets/static/favicon.png +0 -0
  39. package/dist/templates/skeletonlib/files.types=checkjs.json +14 -0
  40. package/dist/templates/skeletonlib/files.types=none.json +10 -0
  41. package/dist/templates/skeletonlib/files.types=typescript.json +14 -0
  42. package/dist/templates/skeletonlib/meta.json +4 -0
  43. package/dist/templates/skeletonlib/package.json +34 -0
  44. package/dist/unocss-Dk7i15rK.js +11 -0
  45. package/dist/unocss-Dk7i15rK.js.map +1 -0
  46. package/dist/unplugin-icons-DkNLYvBs.js +11 -0
  47. package/dist/unplugin-icons-DkNLYvBs.js.map +1 -0
  48. package/package.json +39 -27
  49. package/.npmignore +0 -14
  50. package/bin/sv.d.ts +0 -1
  51. package/bin/sv.js +0 -124
  52. package/common.d.ts +0 -38
  53. package/common.js +0 -27
  54. package/docs/example.js +0 -57
  55. package/index.d.ts +0 -12
  56. package/index.js +0 -29
  57. package/parser.d.ts +0 -29
  58. package/parser.js +0 -194
  59. package/stringifier.d.ts +0 -42
  60. package/stringifier.js +0 -159
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "SvelteKit demo app",
3
+ "description": "A demo app showcasing some of the features of SvelteKit - play a word guessing game that works without JavaScript!"
4
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "~TODO~",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build",
7
+ "preview": "vite preview"
8
+ },
9
+ "devDependencies": {
10
+ "@fontsource/fira-mono": "^5.0.0",
11
+ "@neoconfetti/svelte": "^2.0.0",
12
+ "@sveltejs/adapter-auto": "^3.0.0",
13
+ "@sveltejs/kit": "^2.0.0",
14
+ "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
15
+ "svelte": "^5.0.0-next.1",
16
+ "vite": "^5.0.3"
17
+ },
18
+ "type": "module"
19
+ }
@@ -0,0 +1,21 @@
1
+ node_modules
2
+
3
+ # Output
4
+ .output
5
+ .vercel
6
+ /.svelte-kit
7
+ /build
8
+
9
+ # OS
10
+ .DS_Store
11
+ Thumbs.db
12
+
13
+ # Env
14
+ .env
15
+ .env.*
16
+ !.env.example
17
+ !.env.test
18
+
19
+ # Vite
20
+ vite.config.js.timestamp-*
21
+ vite.config.ts.timestamp-*
@@ -0,0 +1 @@
1
+ engine-strict=true
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%sveltekit.assets%/favicon.png" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ %sveltekit.head%
8
+ </head>
9
+ <body data-sveltekit-preload-data="hover">
10
+ <div style="display: contents">%sveltekit.body%</div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "name": "src/app.d.ts",
4
+ "contents": "// See https://kit.svelte.dev/docs/types#app\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
5
+ },
6
+ {
7
+ "name": "src/lib/index.js",
8
+ "contents": "// place files you want to import through the `$lib` alias in this folder.\n"
9
+ },
10
+ {
11
+ "name": "src/routes/+page.svelte",
12
+ "contents": "<h1>Welcome to SvelteKit</h1>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
13
+ }
14
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "name": "src/lib/index.js",
4
+ "contents": "// place files you want to import through the `$lib` alias in this folder.\n"
5
+ },
6
+ {
7
+ "name": "src/routes/+page.svelte",
8
+ "contents": "<h1>Welcome to SvelteKit</h1>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
9
+ }
10
+ ]
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "name": "src/app.d.ts",
4
+ "contents": "// See https://kit.svelte.dev/docs/types#app\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
5
+ },
6
+ {
7
+ "name": "src/lib/index.ts",
8
+ "contents": "// place files you want to import through the `$lib` alias in this folder.\n"
9
+ },
10
+ {
11
+ "name": "src/routes/+page.svelte",
12
+ "contents": "<h1>Welcome to SvelteKit</h1>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
13
+ }
14
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "Skeleton project",
3
+ "description": "Barebones scaffolding for your new SvelteKit app"
4
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "~TODO~",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "vite dev",
7
+ "build": "vite build",
8
+ "preview": "vite preview"
9
+ },
10
+ "devDependencies": {
11
+ "@sveltejs/adapter-auto": "^3.0.0",
12
+ "@sveltejs/kit": "^2.0.0",
13
+ "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
14
+ "svelte": "^5.0.0-next.1",
15
+ "vite": "^5.0.3"
16
+ },
17
+ "type": "module"
18
+ }
@@ -0,0 +1,22 @@
1
+ node_modules
2
+
3
+ # Output
4
+ .output
5
+ .vercel
6
+ /.svelte-kit
7
+ /build
8
+ /dist
9
+
10
+ # OS
11
+ .DS_Store
12
+ Thumbs.db
13
+
14
+ # Env
15
+ .env
16
+ .env.*
17
+ !.env.example
18
+ !.env.test
19
+
20
+ # Vite
21
+ vite.config.js.timestamp-*
22
+ vite.config.ts.timestamp-*
@@ -0,0 +1 @@
1
+ engine-strict=true
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%sveltekit.assets%/favicon.png" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ %sveltekit.head%
8
+ </head>
9
+ <body data-sveltekit-preload-data="hover">
10
+ <div>%sveltekit.body%</div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "name": "src/app.d.ts",
4
+ "contents": "// See https://kit.svelte.dev/docs/types#app\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
5
+ },
6
+ {
7
+ "name": "src/lib/index.js",
8
+ "contents": "// Reexport your entry components here\n"
9
+ },
10
+ {
11
+ "name": "src/routes/+page.svelte",
12
+ "contents": "<h1>Welcome to your library project</h1>\n<p>Create your package using @sveltejs/package and preview/showcase your work with SvelteKit</p>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
13
+ }
14
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "name": "src/lib/index.js",
4
+ "contents": "// Reexport your entry components here\n"
5
+ },
6
+ {
7
+ "name": "src/routes/+page.svelte",
8
+ "contents": "<h1>Welcome to your library project</h1>\n<p>Create your package using @sveltejs/package and preview/showcase your work with SvelteKit</p>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
9
+ }
10
+ ]
@@ -0,0 +1,14 @@
1
+ [
2
+ {
3
+ "name": "src/app.d.ts",
4
+ "contents": "// See https://kit.svelte.dev/docs/types#app\n// for information about these interfaces\ndeclare global {\n\tnamespace App {\n\t\t// interface Error {}\n\t\t// interface Locals {}\n\t\t// interface PageData {}\n\t\t// interface PageState {}\n\t\t// interface Platform {}\n\t}\n}\n\nexport {};\n"
5
+ },
6
+ {
7
+ "name": "src/lib/index.ts",
8
+ "contents": "// Reexport your entry components here\n"
9
+ },
10
+ {
11
+ "name": "src/routes/+page.svelte",
12
+ "contents": "<h1>Welcome to your library project</h1>\n<p>Create your package using @sveltejs/package and preview/showcase your work with SvelteKit</p>\n<p>Visit <a href=\"https://kit.svelte.dev\">kit.svelte.dev</a> to read the documentation</p>\n"
13
+ }
14
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "title": "Library project",
3
+ "description": "Barebones scaffolding for your new Svelte library"
4
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "~TODO~",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build && npm run package",
7
+ "preview": "vite preview",
8
+ "package": "svelte-kit sync && svelte-package && publint",
9
+ "prepublishOnly": "npm run package"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "svelte": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": ["dist", "!dist/**/*.test.*", "!dist/**/*.spec.*"],
18
+ "peerDependencies": {
19
+ "svelte": "^5.0.0-next.1"
20
+ },
21
+ "devDependencies": {
22
+ "@sveltejs/adapter-auto": "^3.0.0",
23
+ "@sveltejs/kit": "^2.0.0",
24
+ "@sveltejs/package": "^2.0.0",
25
+ "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
26
+ "publint": "^0.2.0",
27
+ "svelte": "^5.0.0-next.1",
28
+ "typescript": "^5.3.2",
29
+ "vite": "^5.0.11"
30
+ },
31
+ "svelte": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "type": "module"
34
+ }
@@ -0,0 +1,11 @@
1
+ var unocss = {
2
+ name: "UnoCSS",
3
+ description: "The instant on-demand Atomic CSS engine",
4
+ category: "CSS",
5
+ npm: "unocss-svelte-integration",
6
+ repo: "https://github.com/owner-name/repo-name",
7
+ website: "https://unocss.dev"
8
+ };
9
+
10
+ export { unocss as default };
11
+ //# sourceMappingURL=unocss-Dk7i15rK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unocss-Dk7i15rK.js","sources":["../../../community-adders/unocss.ts"],"sourcesContent":["import type { CommunityAdder } from '../packages/adders/_config/community.ts';\n\nexport default {\n\tname: 'UnoCSS',\n\tdescription: 'The instant on-demand Atomic CSS engine',\n\tcategory: 'CSS',\n\tnpm: 'unocss-svelte-integration',\n\trepo: 'https://github.com/owner-name/repo-name',\n\twebsite: 'https://unocss.dev'\n} satisfies CommunityAdder;\n"],"names":[],"mappings":"AAEA,aAAe;AAAA,EACd,IAAM,EAAA,QAAA;AAAA,EACN,WAAa,EAAA,yCAAA;AAAA,EACb,QAAU,EAAA,KAAA;AAAA,EACV,GAAK,EAAA,2BAAA;AAAA,EACL,IAAM,EAAA,yCAAA;AAAA,EACN,OAAS,EAAA,oBAAA;AACV,CAAA;;;;"}
@@ -0,0 +1,11 @@
1
+ var unpluginIcons = {
2
+ name: "unplugin-icons",
3
+ description: "Access thousands of icons as components on-demand universally",
4
+ category: "Icon",
5
+ npm: "unplugin-icons-svelte-integration",
6
+ repo: "https://github.com/owner-name/repo-name",
7
+ website: "https://github.com/unplugin/unplugin-icons"
8
+ };
9
+
10
+ export { unpluginIcons as default };
11
+ //# sourceMappingURL=unplugin-icons-DkNLYvBs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin-icons-DkNLYvBs.js","sources":["../../../community-adders/unplugin-icons.ts"],"sourcesContent":["import type { CommunityAdder } from '../packages/adders/_config/community.ts';\n\nexport default {\n\tname: 'unplugin-icons',\n\tdescription: 'Access thousands of icons as components on-demand universally',\n\tcategory: 'Icon',\n\tnpm: 'unplugin-icons-svelte-integration',\n\trepo: 'https://github.com/owner-name/repo-name',\n\twebsite: 'https://github.com/unplugin/unplugin-icons'\n} satisfies CommunityAdder;\n"],"names":[],"mappings":"AAEA,oBAAe;AAAA,EACd,IAAM,EAAA,gBAAA;AAAA,EACN,WAAa,EAAA,+DAAA;AAAA,EACb,QAAU,EAAA,MAAA;AAAA,EACV,GAAK,EAAA,mCAAA;AAAA,EACL,IAAM,EAAA,yCAAA;AAAA,EACN,OAAS,EAAA,4CAAA;AACV,CAAA;;;;"}
package/package.json CHANGED
@@ -1,40 +1,52 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.4.2",
4
- "description": "Any separated values.",
3
+ "version": "0.5.0",
4
+ "description": "A CLI for creating and updating SvelteKit projects",
5
5
  "keywords": [
6
- "any",
7
- "separated",
8
- "values",
9
- "csv",
10
- "tsv",
11
- "tabular",
12
- "tables"
6
+ "create",
7
+ "new",
8
+ "project",
9
+ "starter",
10
+ "svelte",
11
+ "sveltekit",
12
+ "template",
13
+ "wizard"
13
14
  ],
14
- "homepage": "https://github.com/chbrown/sv",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/chbrown/sv.git"
17
+ "url": "https://github.com/sveltejs/cli",
18
+ "directory": "packages/cli"
18
19
  },
19
- "author": "Christopher Brown <io@henrian.com> (http://henrian.com)",
20
20
  "license": "MIT",
21
- "dependencies": {
22
- "async": "*",
23
- "optimist": "*",
24
- "streaming": "*"
21
+ "homepage": "https://kit.svelte.dev",
22
+ "bin": "./dist/bin.js",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
25
28
  },
26
29
  "devDependencies": {
27
- "coveralls": "*",
28
- "declarations": "*",
29
- "istanbul": "*",
30
- "mocha": "*",
31
- "mocha-lcov-reporter": "*",
32
- "typescript": "*"
30
+ "@types/tar-fs": "^2.0.4",
31
+ "commander": "^12.1.0",
32
+ "empathic": "^1.0.0",
33
+ "package-manager-detector": "^0.2.2",
34
+ "picocolors": "^1.1.0",
35
+ "tar-fs": "^3.0.6",
36
+ "tinyexec": "^0.3.0",
37
+ "valibot": "^0.41.0",
38
+ "@sveltejs/adders": "0.0.0",
39
+ "@sveltejs/cli-core": "0.0.0",
40
+ "@sveltejs/clack-prompts": "0.9.1",
41
+ "@sveltejs/create": "0.0.0"
33
42
  },
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "type": "module",
34
47
  "scripts": {
35
- "test": "make test"
36
- },
37
- "bin": {
38
- "sv": "bin/sv.js"
48
+ "lint": "prettier --check . --config ../../.prettierrc --ignore-path ../../.gitignore --ignore-path .gitignore --ignore-path ../../.prettierignore",
49
+ "format": "pnpm lint --write",
50
+ "check": "tsc"
39
51
  }
40
- }
52
+ }
package/.npmignore DELETED
@@ -1,14 +0,0 @@
1
- tests/basic.ts
2
- tests/pairs.ts
3
- tests/quotes.ts
4
- tests/throughput.ts
5
- bin/sv.ts
6
- common.ts
7
- index.ts
8
- parser.ts
9
- stringifier.ts
10
- .travis.yml
11
- Makefile
12
- tsconfig.json
13
- tests/
14
- coverage/
package/bin/sv.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function main(): void;
package/bin/sv.js DELETED
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var optimist = require('optimist');
4
- var fs_1 = require('fs');
5
- var async_1 = require('async');
6
- var index_1 = require('../index');
7
- function main() {
8
- var argvparser = optimist
9
- .usage([
10
- 'Consolidate any tabular format.',
11
- '',
12
- 'Usage: <sprints.txt sv [options] > sprints.csv',
13
- ' or: sv [options] ~/Desktop/**/*.csv > ~/all.csv',
14
- '',
15
- 'Parser options:',
16
- ' --in-delimiter field separator (inferred if unspecified)',
17
- ' --in-quotechar " ',
18
- ' --in-json parse input as JSON (one object per row)',
19
- '',
20
- 'Stringifier options:',
21
- ' --peek 10 infer columns from first ten objects of input',
22
- ' --out-delimiter , field separator',
23
- ' --out-quotechar " marks beginning and end of fields containing delimiter',
24
- ' --filter a,b keep only fields a and b in the results',
25
- ' --omit c,d leave out fields x and y from the results (processed before filter)',
26
- ' -j, --json write one JSON object per row',
27
- '',
28
- 'Other options:',
29
- ' --version print version and quit',
30
- ' -v --verbose turn up the verbosity (still all on STDERR)',
31
- '',
32
- 'STDIN, if supplied, will be coerced to utf8',
33
- ].join('\n'))
34
- .options({
35
- json: {
36
- alias: 'j',
37
- type: 'boolean',
38
- },
39
- 'in-json': {
40
- type: 'boolean',
41
- },
42
- delimiter: {
43
- type: 'string',
44
- },
45
- quotechar: {
46
- type: 'string',
47
- },
48
- escapechar: {
49
- type: 'string',
50
- },
51
- help: {
52
- alias: 'h',
53
- describe: 'print this help message',
54
- type: 'boolean',
55
- },
56
- verbose: {
57
- alias: 'v',
58
- describe: 'print extra output',
59
- type: 'boolean',
60
- },
61
- version: {
62
- describe: 'print version',
63
- type: 'boolean',
64
- },
65
- });
66
- var argv = argvparser.argv;
67
- var parser_opts = {
68
- delimiter: argv['in-delimiter'],
69
- quotechar: argv['in-quotechar'],
70
- json: argv['in-json'],
71
- };
72
- var stringifier_opts = {
73
- delimiter: argv['out-delimiter'],
74
- quotechar: argv['out-quotechar'],
75
- peek: argv.peek,
76
- filter: argv.filter,
77
- omit: argv.omit,
78
- json: argv.json,
79
- width: argv.width,
80
- };
81
- function exit(err) {
82
- if (err && err.code !== 'EPIPE') {
83
- throw err;
84
- }
85
- // if err.code == 'EPIPE' that just means that someone down
86
- // the line cut us short with a | head or something
87
- if (argv.verbose) {
88
- console.error('Done.');
89
- }
90
- // process.exit(); // wait for stdout to finish, actually.
91
- }
92
- if (argv.help) {
93
- argvparser.showHelp();
94
- console.log('ARGV: ' + process.argv.join(' '));
95
- if (argv.verbose) {
96
- console.log(' argv: ' + JSON.stringify(argv, null, ' ').replace(/\n/g, '\n '));
97
- }
98
- console.log(' parser options: ' + JSON.stringify(parser_opts, null, ' ').replace(/\n/g, '\n '));
99
- console.log(' stringifier options: ' + JSON.stringify(stringifier_opts, null, ' ').replace(/\n/g, '\n '));
100
- }
101
- else if (argv.version) {
102
- console.log(require('../package').version);
103
- }
104
- else if (!process.stdin['isTTY']) {
105
- // process.stdin.setEncoding('utf8');
106
- index_1.transform(process.stdin, parser_opts, stringifier_opts, exit);
107
- }
108
- else if (argv._.length) {
109
- var filepaths = argv._;
110
- async_1.eachSeries(filepaths, function (filepath, callback) {
111
- var stream = fs_1.createReadStream(filepath);
112
- index_1.transform(stream, parser_opts, stringifier_opts, callback);
113
- console.error(''); // newline
114
- }, exit);
115
- }
116
- else {
117
- argvparser.showHelp();
118
- console.error('You must supply data via STDIN or as unflagged command line arguments.');
119
- }
120
- }
121
- exports.main = main;
122
- if (require.main === module) {
123
- main();
124
- }
package/common.d.ts DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- - `encoding` for converting to strings.
3
- - `missing` is the value we use for 'time' when we have `columns = ['index', 'time']` and `write({index: 90})` is called.
4
- - `columns` is an array of strings used as object keys. Inferred by default (but after inferring `delimiter`)
5
- - `delimiter` is the field separator used for incoming strings, ',' for csv, '\t' for tsv, etc.
6
- - `quote` is the value that designates a string in which there might be delimiters to ignore. Defaults to '"'
7
- - `escape` is the character that escapes special characters in a quoted field
8
- */
9
- export interface Configuration {
10
- /** character encoding */
11
- encoding?: string;
12
- /** string to represent missing data */
13
- missing?: string;
14
- /** string to separate rows */
15
- newline?: string;
16
- /** string to separate cells in a single row */
17
- delimiter?: string;
18
- /** string to use to nest cell content which contains special characters,
19
- like newline or delimiter */
20
- quotechar?: string;
21
- /** the character that escapes special characters in a quoted field */
22
- escape?: string;
23
- /** the list of columns */
24
- columns?: string[];
25
- }
26
- /**
27
- Like reverse Object.assign, but with special treatment for undefined.
28
- */
29
- export declare function merge(target: {
30
- [index: string]: any;
31
- }, ...sources: {
32
- [index: string]: any;
33
- }[]): {
34
- [index: string]: any;
35
- };
36
- export declare function zip<T>(keys: string[], values: T[], missing: T): {
37
- [index: string]: T;
38
- };
package/common.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /**
3
- Like reverse Object.assign, but with special treatment for undefined.
4
- */
5
- function merge(target) {
6
- var sources = [];
7
- for (var _i = 1; _i < arguments.length; _i++) {
8
- sources[_i - 1] = arguments[_i];
9
- }
10
- sources.forEach(function (source) {
11
- Object.keys(source).filter(function (key) { return source.hasOwnProperty(key); }).forEach(function (key) {
12
- if (target[key] === undefined) {
13
- target[key] = source[key];
14
- }
15
- });
16
- });
17
- return target;
18
- }
19
- exports.merge = merge;
20
- function zip(keys, values, missing) {
21
- var object = {};
22
- for (var i = 0, l = keys.length; i < l; i++) {
23
- object[keys[i]] = values[i] || missing;
24
- }
25
- return object;
26
- }
27
- exports.zip = zip;
package/docs/example.js DELETED
@@ -1,57 +0,0 @@
1
- var sv = require('./'); // require('sv') elsewhere
2
-
3
- function stringify() {
4
- var expenses = [
5
- {name: 'Tip' },
6
- {name: 'Lunch', amount: 5.90},
7
- {name: 'Latte', amount: 3.15},
8
- {name: 'Paper', amount: 2.10},
9
- {name: 'Pens' , amount: 4.59},
10
- { amount: 9.16}
11
- ];
12
-
13
- var stringifier = new sv.Stringifier({peek: 2, missing: 'n/a'});
14
- stringifier.pipe(process.stdout);
15
- expenses.forEach(function(expense) {
16
- stringifier.write(expense);
17
- });
18
- stringifier.end();
19
- }
20
-
21
- function parse() {
22
- var doc = [
23
- 'name,amount',
24
- 'Tip,n/a',
25
- 'Lunch,5.9',
26
- 'Latte,3.15',
27
- 'Paper,2.1',
28
- 'Pens,4.59',
29
- 'n/a,9.16'
30
- ].join('\n');
31
-
32
- var parser = new sv.Parser();
33
- parser.on('data', function(row) {
34
- console.log(row);
35
- });
36
- parser.end(doc);
37
- }
38
-
39
- function stdin() {
40
- var parser = new sv.Parser();
41
- // logEvents(parser, 'parser', ['finish', 'close', 'drain', 'error']);
42
- // logEvents(process.stdout, 'process.stdout', ['end', 'finish', 'close', 'drain', 'error']);
43
- // process.stdout.on('error', function(row) {
44
- // console.log('error', row);
45
- // });
46
- parser.on('data', function(row) {
47
- console.log(row);
48
- });
49
- // parser.pipe(process.stdout);
50
- process.stdin.pipe(parser);
51
- }
52
-
53
- console.log("stringify example");
54
- stringify();
55
-
56
- console.log("parse example");
57
- parse();
package/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { Parser, ParserConfiguration } from './parser';
2
- import { Stringifier, StringifierConfiguration } from './stringifier';
3
- export interface TransformParserConfiguration extends ParserConfiguration {
4
- json?: boolean;
5
- }
6
- export interface TransformStringifierConfiguration extends StringifierConfiguration {
7
- filter?: string;
8
- omit?: string;
9
- json?: boolean;
10
- }
11
- export { Parser, Stringifier };
12
- export declare function transform(input: NodeJS.ReadableStream, parserConfig: TransformParserConfiguration, stringifierConfig: TransformStringifierConfiguration, callback: (error?: Error) => void): void;