Skip to content

Commit

Permalink
[ProjectConverter] Refactor BaseConverter into UrlHandler, ProjectCon…
Browse files Browse the repository at this point in the history
…verter (#224)

* Refactor BaseConverter into UrlHandler, ProjectConverter

* fix the includes comment to explain the complexity of it

* respond to @usergenic PR feedback

* fix basePackageName unsafe reference

* comment on shadycss handling logic

* fix lazy endswith() matching

* remove bad url check

* npm run format

* regex too broad, lets get specific

* respond to justin feedback
  • Loading branch information
FredKSchott authored Nov 16, 2017
1 parent 739d327 commit 6b7b6cf
Show file tree
Hide file tree
Showing 19 changed files with 764 additions and 718 deletions.
68 changes: 0 additions & 68 deletions src/analysis-converter.ts

This file was deleted.

153 changes: 0 additions & 153 deletions src/base-converter.ts

This file was deleted.

11 changes: 1 addition & 10 deletions src/cli/command-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ export default async function run(options: CliOptions) {
inPackageJson && inPackageJson.version ||
outPackageJson && outPackageJson.version;

let bowerMainAny = (inBowerJson && inBowerJson.main) || [];
if (!Array.isArray(bowerMainAny)) {
bowerMainAny = [bowerMainAny];
}
const bowerMain: string[] =
bowerMainAny.filter((m: any) => typeof m === 'string');

const mainFiles = [...bowerMain, ...options.include];

// Prompt user for new package name & version if none exists
// TODO(fks) 07-19-2017: Add option to suppress prompts
if (typeof npmPackageName !== 'string') {
Expand All @@ -96,6 +87,7 @@ export default async function run(options: CliOptions) {

console.log(
chalk.dim('[1/2]') + ' 🌀 ' + chalk.magenta(`Converting Package...`));
console.log(`Out directory: ${outDir}`);

await convertPackage({
inDir: inDir,
Expand All @@ -105,7 +97,6 @@ export default async function run(options: CliOptions) {
packageName: npmPackageName.toLowerCase(),
packageVersion: npmPackageVersion,
cleanOutDir: options.clean!!,
mainFiles,
});

console.log(
Expand Down
32 changes: 24 additions & 8 deletions src/conversion-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,33 @@ export interface ConversionSettings {
/**
* Namespace names used to detect exports.
*/
readonly namespaces: ReadonlySet<string>;
readonly namespaces: Set<string>;
/**
* Files to exclude from conversion (ie lib/utils/boot.html).
*/
readonly excludes: ReadonlySet<string>;
readonly excludes: Set<string>;
/**
* Additional files to include in conversion. By default, all files HTML
* imported somewhere in the project (excluding external packages) are
* included for conversion.
* Files to include in JS conversion. By default this is all local files that
* are imported anywhere inside the package. It is up to the conversion setup
* to make sure this includes any entrypoints into the package (that would
* never be imported themselves).
*
* Any files marked for conversion but not included in this set will be
* converted in-place, remaining HTML. This is preferable for HTML entrypoints
* like tests, demos, etc.
*
* Example: In "paper-input", `includes` by default will include all local
* HTML files imported within the package (paper-input-behavior.html,
* paper-input-error.html, etc). The package conversion setup is responsible
* for adding the main package entrypoint (paper-input.html) as well. Other
* entrypoints (test/index.html, demo/index.html, etc) that are not a part of
* the module code should not be included in `includes` so that they remain
* HTML files after conversion is complete.
*
* TODO(fks) 11-13-2017: Simplify this relationship and what it means to be
* "marked for JS conversion" vs. "marked for HTML in-place conversion".
*/
readonly includes: ReadonlySet<string>;
readonly includes: Set<string>;
/**
* Namespace references (ie, Polymer.DomModule) to "exclude" in the conversion
* by replacing the entire reference with `undefined`. This assumes that those
Expand All @@ -47,14 +63,14 @@ export interface ConversionSettings {
*
* ex: `if(Polymer.DomModule) {...` -> `if (undefined) {...`
*/
readonly referenceExcludes: ReadonlySet<string>;
readonly referenceExcludes: Set<string>;
/**
* Namespace references (ie, document.currentScript.ownerDocument) to
* "rewrite" be replacing the entire reference with the given Node.
*
* ex: `document.currentScript.ownerDocument` -> `window.document`
*/
readonly referenceRewrites: ReadonlyMap<string, estree.Node>;
readonly referenceRewrites: Map<string, estree.Node>;
}

/**
Expand Down
Loading

0 comments on commit 6b7b6cf

Please sign in to comment.