Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-template-recast

Package Overview
Dependencies
Maintainers
7
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-template-recast - npm Package Compare versions

Comparing version 5.0.3 to 6.0.0

17

lib/bin.js

@@ -27,5 +27,5 @@ #!/usr/bin/env node

const os = __importStar(require("os"));
const commander_1 = __importDefault(require("commander"));
const commander_1 = require("commander");
const runner_1 = __importDefault(require("./runner"));
commander_1.default
commander_1.program
.version(require('../package').version)

@@ -38,13 +38,14 @@ .usage('<files> -t transform-plugin.js')

.parse(process.argv);
if (commander_1.default.args.length < 1 || !commander_1.default.transform) {
commander_1.default.help();
const programOptions = commander_1.program.opts();
if (commander_1.program.args.length < 1 || !programOptions.transform) {
commander_1.program.help();
}
else {
const options = {
cpus: commander_1.default.cpus,
dry: commander_1.default.dry,
silent: commander_1.default.silent,
cpus: programOptions.cpus,
dry: programOptions.dry,
silent: programOptions.silent,
};
runner_1.default(commander_1.default.transform, commander_1.default.args, options);
(0, runner_1.default)(programOptions.transform, commander_1.program.args, options);
}
//# sourceMappingURL=bin.js.map
import { traverse, builders, Walker } from '@glimmer/syntax';
import type { AST, NodeVisitor } from '@glimmer/syntax';
import type { ASTv1 as AST, NodeVisitor } from '@glimmer/syntax';
export declare function parse(template: string): AST.Template;

@@ -4,0 +4,0 @@ export declare function print(ast: AST.Node): string;

@@ -21,3 +21,3 @@ "use strict";

if (parseResult === undefined) {
return syntax_1.print(ast, {
return (0, syntax_1.print)(ast, {
entityEncoding: 'raw',

@@ -75,3 +75,3 @@ override: (ast) => {

const visitor = plugin(env);
syntax_1.traverse(ast, visitor);
(0, syntax_1.traverse)(ast, visitor);
return { ast, code: print(ast) };

@@ -78,0 +78,0 @@ }

@@ -1,2 +0,2 @@

import { AST } from '@glimmer/syntax';
import { ASTv1 as AST } from '@glimmer/syntax';
export interface NodeInfo {

@@ -3,0 +3,0 @@ node: AST.Node;

@@ -34,5 +34,5 @@ "use strict";

function fixASTIssues(sourceLines, ast) {
syntax_1.traverse(ast, {
(0, syntax_1.traverse)(ast, {
AttrNode(node) {
const source = utils_1.sourceForLoc(sourceLines, node.loc);
const source = (0, utils_1.sourceForLoc)(sourceLines, node.loc);
const attrNodePartsResults = source.match(attrNodeParts);

@@ -48,4 +48,4 @@ if (attrNodePartsResults === null) {

// always assume the attribute ends on the starting line
node.loc.end.line = node.loc.start.line;
node.loc.end.column = node.loc.start.column + node.name.length;
const { start: { line, column }, } = node.loc;
node.loc = syntax_1.builders.loc(line, column, line, column + node.name.length);
}

@@ -56,3 +56,2 @@ node.isValueless = isValueless;

TextNode(node, path) {
const source = utils_1.sourceForLoc(sourceLines, node.loc);
if (path.parentNode === null) {

@@ -63,7 +62,8 @@ throw new Error('ember-template-recast: Error while sanitizing input AST: found TextNode with no parentNode');

case 'AttrNode': {
const source = (0, utils_1.sourceForLoc)(sourceLines, node.loc);
if (node.chars.length > 0 &&
((source.startsWith(`'`) && source.endsWith(`'`)) ||
(source.startsWith(`"`) && source.endsWith(`"`)))) {
node.loc.end.column = node.loc.end.column - 1;
node.loc.start.column = node.loc.start.column + 1;
const { start, end } = node.loc;
node.loc = syntax_1.builders.loc(start.line, start.column + 1, end.line, end.column - 1);
}

@@ -73,8 +73,12 @@ break;

case 'ConcatStatement': {
// TODO: manually working around https://github.com/glimmerjs/glimmer-vm/pull/954
const parent = path.parentNode;
const isFirstPart = parent.parts.indexOf(node) === 0;
const { start, end } = node.loc;
if (isFirstPart && node.loc.start.column > path.parentNode.loc.start.column + 1) {
node.loc.start.column = node.loc.start.column - 1;
// TODO: manually working around https://github.com/glimmerjs/glimmer-vm/pull/954
node.loc = syntax_1.builders.loc(start.line, start.column - 1, end.line, end.column);
}
else if (isFirstPart && node.chars.charAt(0) === '\n') {
node.loc = syntax_1.builders.loc(start.line, start.column + 1, end.line, end.column);
}
}

@@ -90,6 +94,6 @@ }

this.dirtyFields = new Map();
let ast = syntax_1.preprocess(template, {
let ast = (0, syntax_1.preprocess)(template, {
mode: 'codemod',
});
const source = utils_1.getLines(template);
const source = (0, utils_1.getLines)(template);
ast = fixASTIssues(source, ast);

@@ -150,3 +154,3 @@ this.source = source;

const value = node[key];
if (typeof value === 'object' && value !== null) {
if (key !== 'loc' && typeof value === 'object' && value !== null) {
const propertyProxy = this.wrapNode({ node, key }, value);

@@ -163,3 +167,3 @@ propertyProxyMap.set(key, propertyProxy);

sourceForLoc(loc) {
return utils_1.sourceForLoc(this.source, loc);
return (0, utils_1.sourceForLoc)(this.source, loc);
}

@@ -298,3 +302,3 @@ markAsDirty(node, property) {

if (nodeInfo === undefined) {
return syntax_1.print(_ast, {
return (0, syntax_1.print)(_ast, {
entityEncoding: 'raw',

@@ -655,3 +659,3 @@ override: (ast) => {

end: block.path.loc.start,
}) + syntax_1.print(ast.path);
}) + (0, syntax_1.print)(ast.path);
// TODO: this is a logic error

@@ -658,0 +662,0 @@ const pathIndex = endSource.indexOf(block.path.original);

@@ -59,3 +59,3 @@ "use strict";

spin(message) {
this.spinner = ora_1.default(message).start();
this.spinner = (0, ora_1.default)(message).start();
}

@@ -151,7 +151,7 @@ updateSpinner(message) {

if (!isRemote) {
return path_1.resolve(process.cwd(), transformFile);
return (0, path_1.resolve)(process.cwd(), transformFile);
}
const contents = await downloadFile(transformFile);
const filePath = tmp_1.default.fileSync();
fs_1.writeFileSync(filePath.name, contents, 'utf8');
(0, fs_1.writeFileSync)(filePath.name, contents, 'utf8');
return filePath.name;

@@ -173,3 +173,3 @@ }

async function getAllFiles(paths) {
const files = await globby_1.default(paths, {
const files = await (0, globby_1.default)(paths, {
// must specify a properly escaped `cwd` because globby infers from

@@ -179,3 +179,3 @@ // process.cwd() directly and without correcting back to posix paths

// https://github.com/sindresorhus/globby/pull/137
cwd: slash_1.default(process.cwd()),
cwd: (0, slash_1.default)(process.cwd()),
expandDirectories: {

@@ -208,3 +208,3 @@ extensions: ['hbs', 'handlebars'],

try {
await async_promise_queue_1.default(worker, files, cpus);
await (0, async_promise_queue_1.default)(worker, files, cpus);
}

@@ -211,0 +211,0 @@ finally {

@@ -1,4 +0,4 @@

import type { AST } from '@glimmer/syntax';
import type { ASTv1 as AST } from '@glimmer/syntax';
export declare function sourceForLoc(source: string | string[], loc?: AST.SourceLocation): string;
export declare function isSynthetic(node: AST.Node): boolean;
export declare function isSyntheticWithNoLocation(node: AST.Node): boolean;
export declare function sortByLoc(a: AST.Node, b: AST.Node): -1 | 0 | 1;

@@ -5,0 +5,0 @@ export declare function compact(array: unknown[]): unknown[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLines = exports.compactJoin = exports.compact = exports.sortByLoc = exports.isSynthetic = exports.sourceForLoc = void 0;
exports.getLines = exports.compactJoin = exports.compact = exports.sortByLoc = exports.isSyntheticWithNoLocation = exports.sourceForLoc = void 0;
const reLines = /(.*?(?:\r\n?|\n|$))/gm;

@@ -41,12 +41,13 @@ function sourceForLoc(source, loc) {

exports.sourceForLoc = sourceForLoc;
function isSynthetic(node) {
function isSyntheticWithNoLocation(node) {
if (node && node.loc) {
return node.loc.source === '(synthetic)';
const { start, end } = node.loc;
return (node.loc.module === '(synthetic)' && start.column === end.column && start.line === end.line);
}
return false;
}
exports.isSynthetic = isSynthetic;
exports.isSyntheticWithNoLocation = isSyntheticWithNoLocation;
function sortByLoc(a, b) {
// be conservative about the location where a new node is inserted
if (isSynthetic(a) || isSynthetic(b)) {
if (isSyntheticWithNoLocation(a) || isSyntheticWithNoLocation(b)) {
return 0;

@@ -53,0 +54,0 @@ }

@@ -57,3 +57,3 @@ "use strict";

function applyTransform(plugin, filePath, contents) {
const results = index_1.transform({
const results = (0, index_1.transform)({
template: contents,

@@ -60,0 +60,0 @@ filePath,

{
"name": "ember-template-recast",
"version": "5.0.3",
"version": "6.0.0",
"description": "Non-destructive template transformer.",

@@ -35,8 +35,8 @@ "keywords": [

"dependencies": {
"@glimmer/reference": "^0.65.0",
"@glimmer/syntax": "^0.65.0",
"@glimmer/validator": "^0.65.0",
"@glimmer/reference": "^0.83.0",
"@glimmer/syntax": "^0.83.0",
"@glimmer/validator": "^0.83.0",
"async-promise-queue": "^1.0.5",
"colors": "^1.4.0",
"commander": "^6.2.1",
"commander": "^8.3.0",
"globby": "^11.0.3",

@@ -46,27 +46,27 @@ "ora": "^5.4.0",

"tmp": "^0.2.1",
"workerpool": "^6.1.4"
"workerpool": "^6.1.5"
},
"devDependencies": {
"@types/common-tags": "^1.8.0",
"@types/jest": "^26.0.23",
"@types/workerpool": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@types/common-tags": "^1.8.1",
"@types/jest": "^27.0.2",
"@types/workerpool": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"broccoli-test-helper": "^2.0.0",
"common-tags": "^1.8.0",
"eslint": "^7.26.0",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"execa": "^5.0.0",
"eslint-plugin-prettier": "^4.0.0",
"execa": "^5.1.1",
"jest": "^26.6.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.0",
"release-it": "^14.6.2",
"release-it-lerna-changelog": "^3.1.0",
"prettier": "^2.4.1",
"release-it": "^14.11.6",
"release-it-lerna-changelog": "^4.0.1",
"ts-jest": "^26.5.6",
"typescript": "~4.2.4"
"typescript": "~4.4.4"
},
"engines": {
"node": "10.* || 12.* || >= 14.*"
"node": "12.* || 14.* || >= 16.*"
},

@@ -73,0 +73,0 @@ "publishConfig": {

@@ -165,3 +165,3 @@ # ember-template-recast

* Dropping support for Node versions (e.g. dropping Node 10 support)
* Dropping support for Node versions (e.g. dropping Node 12 support)
* Non-additive changes to the underlying AST (which we bundle from `@glimmer/syntax`)

@@ -168,0 +168,0 @@ * Breaking changes to the `@glimmer/syntax` builder APIs

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc