Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
5 changes: 0 additions & 5 deletions packages/ast-tooling/README.md

This file was deleted.

40 changes: 0 additions & 40 deletions packages/ast-tooling/package.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/ast-tooling/tsconfig.json

This file was deleted.

72 changes: 0 additions & 72 deletions packages/ast-tooling/utils.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/ast-tooling/vitest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export type * from './addon/options.ts';
export type * from './addon/config.ts';
export type * from './addon/workspace.ts';

export { Walker } from '@sveltejs/ast-tooling';
export { Walker } from './tooling/utils.ts';
16 changes: 12 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@
"default": "./dist/parsers.js"
}
},
"dependencies": {
"@sveltejs/ast-tooling": "workspace:*"
},
"devDependencies": {
"@sveltejs/acorn-typescript": "^1.0.1",
"@sveltejs/clack-prompts": "workspace:*",
"@types/estree": "^1.0.6",
"acorn": "^8.14.0",
"decircular": "^1.0.0",
"dedent": "^1.5.3",
"dom-serializer": "^2.0.0",
"domhandler": "^5.0.3",
"domutils": "^3.1.0",
"esrap": "^1.4.5",
"htmlparser2": "^9.1.0",
"magic-string": "^0.30.15",
"picocolors": "^1.1.1"
"picocolors": "^1.1.1",
"postcss": "^8.4.49",
"silver-fleece": "^1.2.1",
"zimmerframe": "^1.1.2"
},
"keywords": [
"create",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import prettier from 'prettier';
import { describe, expect, test } from 'vitest';
import { parseCss, serializeCss } from '@sveltejs/ast-tooling';
import { parseCss, serializeCss } from '../../tooling/utils.ts';

const baseDir = resolve(fileURLToPath(import.meta.url), '..');
const categoryDirectories = getDirectoryNames(baseDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import prettier from 'prettier';
import { describe, expect, test } from 'vitest';
import { parseHtml, serializeHtml } from '@sveltejs/ast-tooling';
import { parseHtml, serializeHtml } from '../../tooling/utils.ts';

const baseDir = resolve(fileURLToPath(import.meta.url), '..');
const categoryDirectories = getDirectoryNames(baseDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import prettier from 'prettier';
import { describe, expect, test } from 'vitest';
import { parseScript, serializeScript } from '@sveltejs/ast-tooling';
import { parseScript, serializeScript } from '../../tooling/utils.ts';

const baseDir = resolve(fileURLToPath(import.meta.url), '..');
const categoryDirectories = getDirectoryNames(baseDir);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest';
import dedent from 'dedent';
import { guessIndentString, guessQuoteStyle } from '../utils.ts';
import { parseScript, serializeScript, type AstTypes } from '../index.ts';
import { guessIndentString, guessQuoteStyle } from '../../core/tooling/utils.ts';
import { parseScript, serializeScript, type AstTypes } from '../tooling/utils.ts';

test('guessIndentString - one tab', () => {
const code = dedent`
Expand Down
9 changes: 1 addition & 8 deletions packages/core/tooling/css/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Declaration,
Rule,
AtRule,
Comment,
type CssAst,
type CssChildNode
} from '@sveltejs/ast-tooling';
import { Declaration, Rule, AtRule, Comment, type CssAst, type CssChildNode } from '../utils.ts';

export type { CssAst };

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
HtmlElement,
HtmlElementType,
parseHtml
} from '@sveltejs/ast-tooling';
} from '../utils.ts';
import { addFromString } from '../js/common.ts';

export { HtmlElement, HtmlElementType };
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/array.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { areNodesEqual } from './common.ts';
import type { AstTypes } from '@sveltejs/ast-tooling';
import type { AstTypes } from '../utils.ts';

export function createEmpty(): AstTypes.ArrayExpression {
const arrayExpression: AstTypes.ArrayExpression = {
Expand Down
8 changes: 1 addition & 7 deletions packages/core/tooling/js/common.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
type AstTypes,
Walker,
parseScript,
serializeScript,
stripAst
} from '@sveltejs/ast-tooling';
import { type AstTypes, Walker, parseScript, serializeScript, stripAst } from '../utils.ts';
import decircular from 'decircular';
import dedent from 'dedent';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/exports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstTypes } from '@sveltejs/ast-tooling';
import type { AstTypes } from '../utils.ts';

export type ExportDefaultReturn<T> = {
astNode: AstTypes.ExportDefaultDeclaration;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstTypes } from '@sveltejs/ast-tooling';
import type { AstTypes } from '../utils.ts';

export function call(name: string, args: string[]): AstTypes.CallExpression {
const callExpression: AstTypes.CallExpression = {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/imports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Walker, type AstTypes } from '@sveltejs/ast-tooling';
import { Walker, type AstTypes } from '../utils.ts';
import { areNodesEqual } from './common.ts';

export function addEmpty(ast: AstTypes.Program, importFrom: string): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export * as imports from './imports.ts';
export * as variables from './variables.ts';
export * as exports from './exports.ts';
export * as kit from './kit.ts';
export type { AstTypes } from '@sveltejs/ast-tooling';
export type { AstTypes } from '../utils.ts';
2 changes: 1 addition & 1 deletion packages/core/tooling/js/kit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Walker, type AstTypes } from '@sveltejs/ast-tooling';
import { Walker, type AstTypes } from '../utils.ts';
import { common, functions, imports, variables, exports } from '../js/index.ts';

export function addGlobalAppInterface(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstTypes } from '@sveltejs/ast-tooling';
import type { AstTypes } from '../utils.ts';

export function property<T extends AstTypes.Expression | AstTypes.Identifier>(
ast: AstTypes.ObjectExpression,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tooling/js/variables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AstTypes } from '@sveltejs/ast-tooling';
import type { AstTypes } from '../utils.ts';

export function declaration(
ast: AstTypes.Program | AstTypes.Declaration,
Expand Down
22 changes: 11 additions & 11 deletions packages/core/tooling/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import * as tools from '@sveltejs/ast-tooling';
import * as utils from './utils.ts';
import MagicString from 'magic-string';

type ParseBase = {
source: string;
generateCode(): string;
};

export function parseScript(source: string): { ast: tools.AstTypes.Program } & ParseBase {
const ast = tools.parseScript(source);
const generateCode = () => tools.serializeScript(ast, source);
export function parseScript(source: string): { ast: utils.AstTypes.Program } & ParseBase {
const ast = utils.parseScript(source);
const generateCode = () => utils.serializeScript(ast, source);

return { ast, source, generateCode };
}

export function parseCss(source: string): { ast: tools.CssAst } & ParseBase {
const ast = tools.parseCss(source);
export function parseCss(source: string): { ast: utils.CssAst } & ParseBase {
const ast = utils.parseCss(source);
const generateCode = () => ast.toString();

return { ast, source, generateCode };
}

export function parseHtml(source: string): { ast: tools.HtmlDocument } & ParseBase {
const ast = tools.parseHtml(source);
const generateCode = () => tools.serializeHtml(ast);
export function parseHtml(source: string): { ast: utils.HtmlDocument } & ParseBase {
const ast = utils.parseHtml(source);
const generateCode = () => utils.serializeHtml(ast);

return { ast, source, generateCode };
}

export function parseJson(source: string): { data: any } & ParseBase {
if (!source) source = '{}';
const data = tools.parseJson(source);
const generateCode = () => tools.serializeJson(source, data);
const data = utils.parseJson(source);
const generateCode = () => utils.serializeJson(source, data);

return { data, source, generateCode };
}
Expand Down
Loading