Merge pull request #2 from imranismail/chore/change-download-path

Support new download path for kustomize
This commit is contained in:
Imran Ismail
2019-11-12 19:39:23 +08:00
committed by GitHub
1455 changed files with 204081 additions and 234805 deletions

View File

@@ -11,7 +11,7 @@ process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer'; import * as installer from '../src/installer';
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = os.platform() === 'win32';
describe('installer tests', () => { describe('installer tests', () => {
beforeAll(async () => { beforeAll(async () => {
@@ -24,9 +24,9 @@ describe('installer tests', () => {
await io.rmRF(tempDir); await io.rmRF(tempDir);
}, 100000); }, 100000);
it('Acquires version of kustomize if no matching version is installed', async () => { it('Acquires kustomize version 3.2.0 successfully', async () => {
await installer.getKustomize('3.1.0'); await installer.getKustomize('3.2.0');
const kustomizeDir = path.join(toolDir, 'kustomize', '3.1.0', os.arch()); const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch());
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true); expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
@@ -37,6 +37,32 @@ describe('installer tests', () => {
} }
}, 100000); }, 100000);
it ('Acquires kustomize version 3.2.1 successfully', async () => {
await installer.getKustomize('3.2.1');
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch());
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true);
}
}, 100000)
it ('Acquires kustomize version 3.3.0 successfully', async () => {
await installer.getKustomize('3.3.0');
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch());
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true);
}
}, 100000)
it('Throws if no location contains correct kustomize version', async () => { it('Throws if no location contains correct kustomize version', async () => {
let thrown = false; let thrown = false;
@@ -45,6 +71,7 @@ describe('installer tests', () => {
} catch { } catch {
thrown = true; thrown = true;
} }
expect(thrown).toBe(true); expect(thrown).toBe(true);
}); });
@@ -60,33 +87,15 @@ describe('installer tests', () => {
return; return;
}); });
it('Doesnt use version of kustomize that was only partially installed in cache', async () => {
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.3.0', os.arch());
await io.mkdirP(kustomizeDir);
let thrown = false;
try {
await installer.getKustomize('3.3.0');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});
it('Resolves semantic versions of kustomize installed in cache', async () => { it('Resolves semantic versions of kustomize installed in cache', async () => {
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.4.0', os.arch()); const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.0.0', os.arch());
await io.mkdirP(kustomizeDir); await io.mkdirP(kustomizeDir);
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello'); fs.writeFileSync(`${kustomizeDir}.complete`, 'hello');
await installer.getKustomize('3.4.0'); await installer.getKustomize('3.0.0');
await installer.getKustomize('3'); // await installer.getKustomize('3.0');
await installer.getKustomize('3.x'); await installer.getKustomize('3.0');
}); });
}); });

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
@@ -23,7 +24,6 @@ const restm = __importStar(require("typed-rest-client/RestClient"));
const os = __importStar(require("os")); const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
const fs = __importStar(require("fs"));
let osPlat = os.platform(); let osPlat = os.platform();
let osArch = os.arch(); let osArch = os.arch();
if (!tempDirectory) { if (!tempDirectory) {
@@ -99,15 +99,15 @@ function queryLatestMatch(versionSpec) {
let kustomizeVersions = (yield rest.get(dataUrl)).result || []; let kustomizeVersions = (yield rest.get(dataUrl)).result || [];
kustomizeVersions.forEach((kustomizeVersion) => { kustomizeVersions.forEach((kustomizeVersion) => {
if (kustomizeVersion.assets.some(asset => asset.name.includes(dataFileName))) { if (kustomizeVersion.assets.some(asset => asset.name.includes(dataFileName))) {
versions.push(kustomizeVersion.name); let version = semver.clean(kustomizeVersion.name);
if (version != null) {
versions.push(version);
}
} }
}); });
// get the latest version that matches the version spec return evaluateVersions(versions, versionSpec);
let version = evaluateVersions(versions, versionSpec);
return version;
}); });
} }
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
function evaluateVersions(versions, versionSpec) { function evaluateVersions(versions, versionSpec) {
let version = ''; let version = '';
core.debug(`evaluating ${versions.length} versions`); core.debug(`evaluating ${versions.length} versions`);
@@ -136,25 +136,39 @@ function evaluateVersions(versions, versionSpec) {
function acquireKustomize(version) { function acquireKustomize(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
version = semver.clean(version) || ''; version = semver.clean(version) || '';
let fileName = `kustomize_${version}`; let downloadUrl;
let downloadPath;
if (semver.gte(version, "3.3.0")) {
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_v${version}_%{os}_%{arch}.tar.gz`;
}
else if (semver.gte(version, "3.2.1")) {
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_kustomize.v${version}_%{os}_%{arch}`;
}
else {
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/v${version}/kustomize_${version}_%{os}_%{arch}`;
}
switch (osPlat) { switch (osPlat) {
case 'win32':
if (semver.lte(version, "3.2.1"))
throw new Error(`Unexpected OS '${osPlat}'`);
downloadUrl = downloadUrl.replace('%{os}', 'windows');
if (semver.lt(version, "3.3.0"))
downloadUrl = `${downloadUrl}.exe`;
break;
case 'linux': case 'linux':
case 'darwin': case 'darwin':
case 'win32': downloadUrl = downloadUrl.replace('%{os}', osPlat);
fileName = `${fileName}_${osPlat}`;
break; break;
default: default:
throw new Error(`Unexpected OS '${osPlat}'`); throw new Error(`Unexpected OS '${osPlat}'`);
} }
switch (osArch) { switch (osArch) {
case 'x64': case 'x64':
fileName = `${fileName}_amd64`; downloadUrl = downloadUrl.replace('%{arch}', 'amd64');
break; break;
default: default:
fileName = `${fileName}_${osArch}`; throw new Error(`Unexpected Arch '${osArch}'`);
} }
let downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/v${version}/${fileName}`;
let downloadPath;
try { try {
downloadPath = yield tc.downloadTool(downloadUrl); downloadPath = yield tc.downloadTool(downloadUrl);
} }
@@ -162,7 +176,14 @@ function acquireKustomize(version) {
core.debug(err); core.debug(err);
throw `Failed to download version ${version}: ${err}`; throw `Failed to download version ${version}: ${err}`;
} }
fs.chmodSync(downloadPath, 0o755); let toolPath = downloadPath;
if (downloadUrl.endsWith('.tar.gz')) {
let extPath = yield tc.extractTar(downloadPath);
toolPath = path.join(extPath, "kustomize");
}
if (osPlat == "win32") {
toolPath = `${toolPath}.exe`;
}
return yield tc.cacheFile(downloadPath, 'kustomize', 'kustomize', version); return yield tc.cacheFile(downloadPath, 'kustomize', 'kustomize', version);
}); });
} }

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };

View File

@@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

109
node_modules/@actions/core/README.md generated vendored
View File

@@ -4,48 +4,55 @@
## Usage ## Usage
#### Inputs/Outputs ### Import the package
You can use this library to get inputs or set outputs: ```js
// javascript
```
const core = require('@actions/core'); const core = require('@actions/core');
const myInput = core.getInput('inputName', { required: true }); // typescript
import * as core from '@actions/core';
```
// Do stuff #### Inputs/Outputs
Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
```js
const myInput = core.getInput('inputName', { required: true });
core.setOutput('outputKey', 'outputVal'); core.setOutput('outputKey', 'outputVal');
``` ```
#### Exporting variables/secrets #### Exporting variables
You can also export variables and secrets for future steps. Variables get set in the environment automatically, while secrets must be scoped into the environment from a workflow using `{{ secret.FOO }}`. Secrets will also be masked from the logs: Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.
```
const core = require('@actions/core');
// Do stuff
```js
core.exportVariable('envVar', 'Val'); core.exportVariable('envVar', 'Val');
core.exportSecret('secretVar', variableWithSecretValue); ```
#### Setting a secret
Setting a secret registers the secret with the runner to ensure it is masked in logs.
```js
core.setSecret('myPassword');
``` ```
#### PATH Manipulation #### PATH Manipulation
You can explicitly add items to the path for all remaining steps in a workflow: To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH.
``` ```js
const core = require('@actions/core'); core.addPath('/path/to/mytool');
core.addPath('pathToTool');
``` ```
#### Exit codes #### Exit codes
You should use this library to set the failing exit code for your action: You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success.
``` ```js
const core = require('@actions/core'); const core = require('@actions/core');
try { try {
@@ -56,13 +63,15 @@ catch (err) {
core.setFailed(`Action failed with error ${err}`); core.setFailed(`Action failed with error ${err}`);
} }
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
``` ```
#### Logging #### Logging
Finally, this library provides some utilities for logging: Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
``` ```js
const core = require('@actions/core'); const core = require('@actions/core');
const myInput = core.getInput('input'); const myInput = core.getInput('input');
@@ -70,12 +79,62 @@ try {
core.debug('Inside try block'); core.debug('Inside try block');
if (!myInput) { if (!myInput) {
core.warning('myInput wasnt set'); core.warning('myInput was not set');
} }
// Do stuff // Do stuff
} }
catch (err) { catch (err) {
core.error('Error ${err}, action may still succeed though'); core.error(`Error ${err}, action may still succeed though`);
} }
``` ```
This library can also wrap chunks of output in foldable groups.
```js
const core = require('@actions/core')
// Manually wrap output
core.startGroup('Do some function')
doSomeFunction()
core.endGroup()
// Wrap an asynchronous function call
const result = await core.group('Do something async', async () => {
const response = await doSomeHTTPRequest()
return response
})
```
#### Action state
You can use this library to save state and get state for sharing information between a given wrapper action:
**action.yml**
```yaml
name: 'Wrapper action sample'
inputs:
name:
default: 'GitHub'
runs:
using: 'node12'
main: 'main.js'
post: 'cleanup.js'
```
In action's `main.js`:
```js
const core = require('@actions/core');
core.saveState("pidToKill", 12345);
```
In action's `cleanup.js`:
```js
const core = require('@actions/core');
var pid = core.getState("pidToKill");
process.kill(pid);
```

View File

@@ -9,8 +9,8 @@ interface CommandProperties {
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void; export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
export declare function issue(name: string, message: string): void; export declare function issue(name: string, message?: string): void;
export {}; export {};

View File

@@ -9,18 +9,18 @@ const os = require("os");
* *
* Examples: * Examples:
* ##[warning]This is the user warning message * ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definatelyNotAPassword! * ##[set-secret name=mypassword]definitelyNotAPassword!
*/ */
function issueCommand(command, properties, message) { function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message); const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL); process.stdout.write(cmd.toString() + os.EOL);
} }
exports.issueCommand = issueCommand; exports.issueCommand = issueCommand;
function issue(name, message) { function issue(name, message = '') {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;
const CMD_PREFIX = '##['; const CMD_STRING = '::';
class Command { class Command {
constructor(command, properties, message) { constructor(command, properties, message) {
if (!command) { if (!command) {
@@ -31,7 +31,7 @@ class Command {
this.message = message; this.message = message;
} }
toString() { toString() {
let cmdStr = CMD_PREFIX + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
for (const key in this.properties) { for (const key in this.properties) {
@@ -40,12 +40,12 @@ class Command {
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)};`; cmdStr += `${key}=${escape(`${val || ''}`)},`;
} }
} }
} }
} }
cmdStr += ']'; cmdStr += CMD_STRING;
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
const message = `${this.message || ''}`; const message = `${this.message || ''}`;

View File

@@ -1 +1 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAe;IACjD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"} {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View File

@@ -19,17 +19,16 @@ export declare enum ExitCode {
Failure = 1 Failure = 1
} }
/** /**
* sets env variable for this action and future actions in the job * Sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable
*/ */
export declare function exportVariable(name: string, val: string): void; export declare function exportVariable(name: string, val: string): void;
/** /**
* exports the variable and registers a secret which will get masked from logs * Registers a secret which will get masked from logs
* @param name the name of the variable to set * @param secret value of the secret
* @param val value of the secret
*/ */
export declare function exportSecret(name: string, val: string): void; export declare function setSecret(secret: string): void;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath * @param inputPath
@@ -71,3 +70,43 @@ export declare function error(message: string): void;
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;
/**
* Writes info to log with console.log.
* @param message info message
*/
export declare function info(message: string): void;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
export declare function startGroup(name: string): void;
/**
* End an output group.
*/
export declare function endGroup(): void;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store
*/
export declare function saveState(name: string, value: string): void;
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
export declare function getState(name: string): string;

View File

@@ -1,6 +1,16 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("./command"); const command_1 = require("./command");
const os = require("os");
const path = require("path"); const path = require("path");
/** /**
* The code to exit an action * The code to exit an action
@@ -20,7 +30,7 @@ var ExitCode;
// Variables // Variables
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* sets env variable for this action and future actions in the job * Sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable
*/ */
@@ -30,15 +40,13 @@ function exportVariable(name, val) {
} }
exports.exportVariable = exportVariable; exports.exportVariable = exportVariable;
/** /**
* exports the variable and registers a secret which will get masked from logs * Registers a secret which will get masked from logs
* @param name the name of the variable to set * @param secret value of the secret
* @param val value of the secret
*/ */
function exportSecret(name, val) { function setSecret(secret) {
exportVariable(name, val); command_1.issueCommand('add-mask', {}, secret);
command_1.issueCommand('set-secret', {}, val);
} }
exports.exportSecret = exportSecret; exports.setSecret = setSecret;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath * @param inputPath
@@ -56,7 +64,7 @@ exports.addPath = addPath;
* @returns string * @returns string
*/ */
function getInput(name, options) { function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
@@ -113,4 +121,75 @@ function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message);
} }
exports.warning = warning; exports.warning = warning;
/**
* Writes info to log with console.log.
* @param message info message
*/
function info(message) {
process.stdout.write(message + os.EOL);
}
exports.info = info;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
exports.endGroup = endGroup;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store
*/
function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value);
}
exports.saveState = saveState;
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
function getState(name) {
return process.env[`STATE_${name}`] || '';
}
exports.getState = getState;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC"} {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC;AAED,yEAAyE;AACzE,uBAAuB;AACvB,yEAAyE;AAEzE;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC"}

View File

@@ -1,37 +1,35 @@
{ {
"_args": [ "_from": "@actions/core@1.2.0",
[ "_id": "@actions/core@1.2.0",
"@actions/core@1.0.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_from": "@actions/core@1.0.0",
"_id": "@actions/core@1.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-aMIlkx96XH4E/2YZtEOeyrYQfhlas9jIRkfGPqMwXD095Rdkzo4lB6ZmbxPQSzD+e1M+Xsm98ZhuSMYGv/AlqA==", "_integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==",
"_location": "/@actions/core", "_location": "/@actions/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/core@1.0.0", "raw": "@actions/core@1.2.0",
"name": "@actions/core", "name": "@actions/core",
"escapedName": "@actions%2fcore", "escapedName": "@actions%2fcore",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.0.0", "rawSpec": "1.2.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.0.0" "fetchSpec": "1.2.0"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER",
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
"_spec": "1.0.0", "_shasum": "aa5f52b26c362c821d41557e599371a42f6c0b3d",
"_spec": "@actions/core@1.2.0",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_where": "/Users/imranismail/Projects/setup-kustomize",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "Actions core lib", "description": "Actions core lib",
"devDependencies": { "devDependencies": {
"@types/node": "^12.0.2" "@types/node": "^12.0.2"
@@ -43,11 +41,11 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core", "homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"keywords": [ "keywords": [
"core", "github",
"actions" "actions",
"core"
], ],
"license": "MIT", "license": "MIT",
"main": "lib/core.js", "main": "lib/core.js",
@@ -57,11 +55,12 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/actions/toolkit.git" "url": "git+https://github.com/actions/toolkit.git",
"directory": "packages/core"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "1.2.0"
} }

12
node_modules/@actions/exec/README.md generated vendored
View File

@@ -6,7 +6,7 @@
You can use this package to execute your tools on the command line in a cross platform way: You can use this package to execute your tools on the command line in a cross platform way:
``` ```js
const exec = require('@actions/exec'); const exec = require('@actions/exec');
await exec.exec('node index.js'); await exec.exec('node index.js');
@@ -16,7 +16,7 @@ await exec.exec('node index.js');
You can also pass in arg arrays: You can also pass in arg arrays:
``` ```js
const exec = require('@actions/exec'); const exec = require('@actions/exec');
await exec.exec('node', ['index.js', 'foo=bar']); await exec.exec('node', ['index.js', 'foo=bar']);
@@ -26,11 +26,11 @@ await exec.exec('node', ['index.js', 'foo=bar']);
Capture output or specify [other options](https://github.com/actions/toolkit/blob/d9347d4ab99fd507c0b9104b2cf79fb44fcc827d/packages/exec/src/interfaces.ts#L5): Capture output or specify [other options](https://github.com/actions/toolkit/blob/d9347d4ab99fd507c0b9104b2cf79fb44fcc827d/packages/exec/src/interfaces.ts#L5):
``` ```js
const exec = require('@actions/exec'); const exec = require('@actions/exec');
const myOutput = ''; let myOutput = '';
const myError = ''; let myError = '';
const options = {}; const options = {};
options.listeners = { options.listeners = {
@@ -50,7 +50,7 @@ await exec.exec('node', ['index.js', 'foo=bar'], options);
You can use it in conjunction with the `which` function from `@actions/io` to execute tools that are not in the PATH: You can use it in conjunction with the `which` function from `@actions/io` to execute tools that are not in the PATH:
``` ```js
const exec = require('@actions/exec'); const exec = require('@actions/exec');
const io = require('@actions/io'); const io = require('@actions/io');

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };

View File

@@ -1 +1 @@
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"} {"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
@@ -188,7 +189,7 @@ class ToolRunner extends events.EventEmitter {
// command line from libuv quoting rules would look like: // command line from libuv quoting rules would look like:
// foo.exe "myarg:\"my val\"" // foo.exe "myarg:\"my val\""
// //
// 3) double-up slashes that preceed a quote, // 3) double-up slashes that precede a quote,
// e.g. hello \world => "hello \world" // e.g. hello \world => "hello \world"
// hello\"world => "hello\\""world" // hello\"world => "hello\\""world"
// hello\\"world => "hello\\\\""world" // hello\\"world => "hello\\\\""world"

File diff suppressed because one or more lines are too long

View File

@@ -1,39 +1,36 @@
{ {
"_args": [ "_from": "@actions/exec@^1.0.1",
[ "_id": "@actions/exec@1.0.1",
"@actions/exec@1.0.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_from": "@actions/exec@1.0.0",
"_id": "@actions/exec@1.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-nquH0+XKng+Ll7rZfCojN7NWSbnGh+ltwUJhzfbLkmOJgxocGX2/yXcZLMyT9fa7+tByEow/NSTrBExNlEj9fw==", "_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
"_location": "/@actions/exec", "_location": "/@actions/exec",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@actions/exec@1.0.0", "raw": "@actions/exec@^1.0.1",
"name": "@actions/exec", "name": "@actions/exec",
"escapedName": "@actions%2fexec", "escapedName": "@actions%2fexec",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.0.0", "rawSpec": "^1.0.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.0.0" "fetchSpec": "^1.0.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
"_spec": "1.0.0", "_shasum": "1624b541165697e7008d7c87bc1f69f191263c6c",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@actions/exec@^1.0.1",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@actions/tool-cache",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "Actions exec lib", "description": "Actions exec lib",
"devDependencies": { "devDependencies": {
"@actions/io": "^1.0.0" "@actions/io": "^1.0.1"
}, },
"directories": { "directories": {
"lib": "lib", "lib": "lib",
@@ -42,11 +39,12 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55", "gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec", "homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [ "keywords": [
"exec", "github",
"actions" "actions",
"exec"
], ],
"license": "MIT", "license": "MIT",
"main": "lib/exec.js", "main": "lib/exec.js",
@@ -62,5 +60,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "1.0.1"
} }

8
node_modules/@actions/io/README.md generated vendored
View File

@@ -8,7 +8,7 @@
Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified: Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:
``` ```js
const io = require('@actions/io'); const io = require('@actions/io');
await io.mkdirP('path/to/make'); await io.mkdirP('path/to/make');
@@ -18,7 +18,7 @@ await io.mkdirP('path/to/make');
Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv): Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):
``` ```js
const io = require('@actions/io'); const io = require('@actions/io');
// Recursive must be true for directories // Recursive must be true for directories
@@ -32,7 +32,7 @@ await io.mv('path/to/file', 'path/to/dest');
Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified. Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.
``` ```js
const io = require('@actions/io'); const io = require('@actions/io');
await io.rmRF('path/to/directory'); await io.rmRF('path/to/directory');
@@ -43,7 +43,7 @@ await io.rmRF('path/to/file');
Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which). Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
``` ```js
const exec = require('@actions/exec'); const exec = require('@actions/exec');
const io = require('@actions/io'); const io = require('@actions/io');

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };

View File

@@ -1 +1 @@
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAyB;AACzB,yBAAwB;AACxB,6BAA4B;AAEf,gBAYE,qTAAA;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,UAAmB,KAAK;;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;;;;;GASG;AACH,SAAsB,MAAM,CAC1B,MAAc,EACd,WAAmB,IAAI,EACvB,QAAgB,CAAC;;QAEjB,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAE9C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE7B,IAAI,KAAK,IAAI,QAAQ;YAAE,OAAO,aAAK,CAAC,MAAM,CAAC,CAAA;QAE3C,IAAI;YACF,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;YACnB,OAAM;SACP;QAAC,OAAO,GAAG,EAAE;YACZ,QAAQ,GAAG,CAAC,IAAI,EAAE;gBAChB,KAAK,QAAQ,CAAC,CAAC;oBACb,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;oBACvD,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;oBACnB,OAAM;iBACP;gBACD,OAAO,CAAC,CAAC;oBACP,IAAI,KAAe,CAAA;oBAEnB,IAAI;wBACF,KAAK,GAAG,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;qBAC3B;oBAAC,OAAO,IAAI,EAAE;wBACb,MAAM,GAAG,CAAA;qBACV;oBAED,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;wBAAE,MAAM,GAAG,CAAA;iBACpC;aACF;SACF;IACH,CAAC;CAAA;AAlCD,wBAkCC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC"} {"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAyB;AACzB,yBAAwB;AACxB,6BAA4B;AAEf,gBAYE,qTAAA;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,UAAmB,KAAK;;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;;;;;GASG;AACH,SAAsB,MAAM,CAC1B,MAAc,EACd,WAAmB,IAAI,EACvB,QAAgB,CAAC;;QAEjB,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAE9C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE7B,IAAI,KAAK,IAAI,QAAQ;YAAE,OAAO,aAAK,CAAC,MAAM,CAAC,CAAA;QAE3C,IAAI;YACF,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;YACnB,OAAM;SACP;QAAC,OAAO,GAAG,EAAE;YACZ,QAAQ,GAAG,CAAC,IAAI,EAAE;gBAChB,KAAK,QAAQ,CAAC,CAAC;oBACb,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;oBACvD,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;oBACnB,OAAM;iBACP;gBACD,OAAO,CAAC,CAAC;oBACP,IAAI,KAAe,CAAA;oBAEnB,IAAI;wBACF,KAAK,GAAG,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;qBAC3B;oBAAC,OAAO,IAAI,EAAE;wBACb,MAAM,GAAG,CAAA;qBACV;oBAED,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;wBAAE,MAAM,GAAG,CAAA;iBACpC;aACF;SACF;IACH,CAAC;CAAA;AAlCD,wBAkCC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC"}

7
node_modules/@actions/io/lib/io.js generated vendored
View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
@@ -204,9 +205,9 @@ function which(tool, check) {
} }
// build the list of directories // build the list of directories
// //
// Note, technically "where" checks the current directory on Windows. From a task lib perspective, // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
// it feels like we should not do this. Checking the current directory seems like more of a use // it feels like we should not do this. Checking the current directory seems like more of a use
// case of a shell, and the which() function exposed by the task lib should strive for consistency // case of a shell, and the which() function exposed by the toolkit should strive for consistency
// across platforms. // across platforms.
const directories = []; const directories = [];
if (process.env.PATH) { if (process.env.PATH) {

File diff suppressed because one or more lines are too long

View File

@@ -1,29 +1,29 @@
{ {
"_from": "@actions/io", "_from": "@actions/io@1.0.1",
"_id": "@actions/io@1.0.0", "_id": "@actions/io@1.0.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-ezrJSRdqtXtdx1WXlfYL85+40F7gB39jCK9P0jZVODW3W6xUYmu6ZOEc/UmmElUwhRyDRm1R4yNZu1Joq2kuQg==", "_integrity": "sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==",
"_location": "/@actions/io", "_location": "/@actions/io",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "tag", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/io", "raw": "@actions/io@1.0.1",
"name": "@actions/io", "name": "@actions/io",
"escapedName": "@actions%2fio", "escapedName": "@actions%2fio",
"scope": "@actions", "scope": "@actions",
"rawSpec": "", "rawSpec": "1.0.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "latest" "fetchSpec": "1.0.1"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER", "#USER",
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz",
"_shasum": "379454174660623bb5b3bce0be8b9e2285a62bcb", "_shasum": "81a9418fe2bbdef2d2717a8e9f85188b9c565aca",
"_spec": "@actions/io", "_spec": "@actions/io@1.0.1",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_where": "/Users/imranismail/Projects/setup-kustomize",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
@@ -38,11 +38,12 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a40bce7c8d382aa3dbadaa327acbc696e9390e55", "gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io", "homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
"keywords": [ "keywords": [
"io", "github",
"actions" "actions",
"io"
], ],
"license": "MIT", "license": "MIT",
"main": "lib/io.js", "main": "lib/io.js",
@@ -58,5 +59,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.0" "version": "1.0.1"
} }

View File

@@ -11,7 +11,7 @@ You can use this to download tools (or other files) from a download URL:
```js ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
``` ```
#### Extract #### Extract
@@ -22,15 +22,15 @@ These can then be extracted in platform specific ways:
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
if (process.platform === 'win32') { if (process.platform === 'win32') {
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip'); const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
// Or alternately // Or alternately
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z'); const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
} }
else { else {
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
} }
``` ```
@@ -45,7 +45,7 @@ You'll often want to add it to the path as part of this step:
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const core = require('@actions/core'); const core = require('@actions/core');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0'); const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');

View File

@@ -1,9 +1,10 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
@@ -217,12 +218,7 @@ function extractZip(file, dest) {
yield extractZipWin(file, dest); yield extractZipWin(file, dest);
} }
else { else {
if (process.platform === 'darwin') { yield extractZipNix(file, dest);
yield extractZipDarwin(file, dest);
}
else {
yield extractZipNix(file, dest);
}
} }
return dest; return dest;
}); });
@@ -251,13 +247,7 @@ function extractZipWin(file, dest) {
} }
function extractZipNix(file, dest) { function extractZipNix(file, dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip'); const unzipPath = yield io.which('unzip');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
function extractZipDarwin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
}); });
} }

File diff suppressed because one or more lines are too long

View File

@@ -1,44 +1,42 @@
{ {
"_args": [ "_from": "@actions/tool-cache@1.1.2",
[ "_id": "@actions/tool-cache@1.1.2",
"@actions/tool-cache@1.1.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_from": "@actions/tool-cache@1.1.0",
"_id": "@actions/tool-cache@1.1.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-Oe/R1Gxv0G699OUL9ypxk9cTwHf1uXHhpcK7kpZt8d/Sbw915ktMkfxXt9+awOfLDwyl54sLi86KGCuSvnRuIQ==", "_integrity": "sha512-IJczPaZr02ECa3Lgws/TJEVco9tjOujiQSZbO3dHuXXjhd5vrUtfOgGwhmz3/f97L910OraPZ8SknofUk6RvOQ==",
"_location": "/@actions/tool-cache", "_location": "/@actions/tool-cache",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/tool-cache@1.1.0", "raw": "@actions/tool-cache@1.1.2",
"name": "@actions/tool-cache", "name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache", "escapedName": "@actions%2ftool-cache",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.1.0", "rawSpec": "1.1.2",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.1.0" "fetchSpec": "1.1.2"
}, },
"_requiredBy": [ "_requiredBy": [
"#USER",
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.2.tgz",
"_spec": "1.1.0", "_shasum": "304d44cecb9547324731e03ca004a3905e6530d2",
"_spec": "@actions/tool-cache@1.1.2",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_where": "/Users/imranismail/Projects/setup-kustomize",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@actions/core": "^1.0.0", "@actions/core": "^1.1.0",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.1",
"@actions/io": "^1.0.0", "@actions/io": "^1.0.1",
"semver": "^6.1.0", "semver": "^6.1.0",
"typed-rest-client": "^1.4.0", "typed-rest-client": "^1.4.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
}, },
"deprecated": false,
"description": "Actions tool-cache lib", "description": "Actions tool-cache lib",
"devDependencies": { "devDependencies": {
"@types/nock": "^10.0.3", "@types/nock": "^10.0.3",
@@ -56,8 +54,9 @@
], ],
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec", "homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [ "keywords": [
"exec", "github",
"actions" "actions",
"exec"
], ],
"license": "MIT", "license": "MIT",
"main": "lib/tool-cache.js", "main": "lib/tool-cache.js",
@@ -73,5 +72,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.1.0" "version": "1.1.2"
} }

Binary file not shown.

Binary file not shown.

View File

@@ -343,7 +343,7 @@ function normalizeOptions(opts) {
delete options.include; delete options.include;
delete options.exclude; delete options.exclude;
if (options.hasOwnProperty("sourceMap")) { if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {
options.sourceMaps = options.sourceMap; options.sourceMaps = options.sourceMap;
delete options.sourceMap; delete options.sourceMap;
} }

View File

@@ -202,7 +202,8 @@ function assertNoDuplicates(items) {
} }
if (nameMap.has(item.name)) { if (nameMap.has(item.name)) {
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`].join("\n")); const conflicts = items.filter(i => i.value === item.value);
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, ``, `Duplicates detected are:`, `${JSON.stringify(conflicts, null, 2)}`].join("\n"));
} }
nameMap.add(item.name); nameMap.add(item.name);

View File

@@ -69,18 +69,16 @@ var _patternToRegex = _interopRequireDefault(require("../pattern-to-regex"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug().default)("babel:config:loading:files:configuration"); const debug = (0, _debug().default)("babel:config:loading:files:configuration");
const BABEL_CONFIG_JS_FILENAME = "babel.config.js"; const ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.json"];
const BABELRC_FILENAME = ".babelrc"; const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs"];
const BABELRC_JS_FILENAME = ".babelrc.js";
const BABELIGNORE_FILENAME = ".babelignore"; const BABELIGNORE_FILENAME = ".babelignore";
function findConfigUpwards(rootDir) { function findConfigUpwards(rootDir) {
let dirname = rootDir; let dirname = rootDir;
while (true) { while (true) {
if (_fs().default.existsSync(_path().default.join(dirname, BABEL_CONFIG_JS_FILENAME))) { const configFileFound = ROOT_CONFIG_FILENAMES.some(filename => _fs().default.existsSync(_path().default.join(dirname, filename)));
return dirname; if (configFileFound) return dirname;
}
const nextDir = _path().default.dirname(dirname); const nextDir = _path().default.dirname(dirname);
@@ -99,30 +97,7 @@ function findRelativeConfig(packageData, envName, caller) {
for (const loc of packageData.directories) { for (const loc of packageData.directories) {
if (!config) { if (!config) {
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce((previousConfig, name) => { config = loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) : null);
const filepath = _path().default.join(loc, name);
const config = readConfig(filepath, envName, caller);
if (config && previousConfig) {
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().default.basename(previousConfig.filepath)}\n` + ` - ${name}\n` + `from ${loc}`);
}
return config || previousConfig;
}, null);
const pkgConfig = packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) : null;
if (pkgConfig) {
if (config) {
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().default.basename(pkgConfig.filepath)}#babel\n` + ` - ${_path().default.basename(config.filepath)}\n` + `from ${loc}`);
}
config = pkgConfig;
}
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
} }
if (!ignore) { if (!ignore) {
@@ -143,15 +118,27 @@ function findRelativeConfig(packageData, envName, caller) {
} }
function findRootConfig(dirname, envName, caller) { function findRootConfig(dirname, envName, caller) {
const filepath = _path().default.resolve(dirname, BABEL_CONFIG_JS_FILENAME); return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
}
const conf = readConfig(filepath, envName, caller); function loadOneConfig(names, dirname, envName, caller, previousConfig = null) {
const config = names.reduce((previousConfig, name) => {
const filepath = _path().default.resolve(dirname, name);
if (conf) { const config = readConfig(filepath, envName, caller);
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname);
if (config && previousConfig) {
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().default.basename(previousConfig.filepath)}\n` + ` - ${name}\n` + `from ${dirname}`);
}
return config || previousConfig;
}, previousConfig);
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
} }
return conf; return config;
} }
function loadConfig(name, dirname, envName, caller) { function loadConfig(name, dirname, envName, caller) {
@@ -170,7 +157,9 @@ function loadConfig(name, dirname, envName, caller) {
} }
function readConfig(filepath, envName, caller) { function readConfig(filepath, envName, caller) {
return _path().default.extname(filepath) === ".js" ? readConfigJS(filepath, { const ext = _path().default.extname(filepath);
return ext === ".js" || ext === ".cjs" ? readConfigJS(filepath, {
envName, envName,
caller caller
}) : readConfigJSON5(filepath); }) : readConfigJSON5(filepath);

View File

@@ -37,7 +37,9 @@ var _partial = _interopRequireDefault(require("./partial"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function loadFullConfig(inputOpts) { function loadFullConfig(inputOpts) {
const result = (0, _partial.default)(inputOpts); const result = (0, _partial.default)(inputOpts);
@@ -159,7 +161,7 @@ const loadDescriptor = (0, _caching.makeWeakCache)(({
let item = value; let item = value;
if (typeof value === "function") { if (typeof value === "function") {
const api = Object.assign({}, context, (0, _configApi.default)(cache)); const api = Object.assign({}, context, {}, (0, _configApi.default)(cache));
try { try {
item = value(api, options, dirname); item = value(api, options, dirname);
@@ -231,8 +233,30 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(({
return new _plugin.default(plugin, options, alias); return new _plugin.default(plugin, options, alias);
}); });
const validateIfOptionNeedsFilename = (options, descriptor) => {
if (options.test || options.include || options.exclude) {
const formattedPresetName = descriptor.name ? `"${descriptor.name}"` : "/* your preset */";
throw new Error([`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`, `\`\`\``, `babel.transform(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`, `\`\`\``, `See https://babeljs.io/docs/en/options#filename for more information.`].join("\n"));
}
};
const validatePreset = (preset, context, descriptor) => {
if (!context.filename) {
const {
options
} = preset;
validateIfOptionNeedsFilename(options, descriptor);
if (options.overrides) {
options.overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor));
}
}
};
const loadPresetDescriptor = (descriptor, context) => { const loadPresetDescriptor = (descriptor, context) => {
return (0, _configChain.buildPresetChain)(instantiatePreset(loadDescriptor(descriptor, context)), context); const preset = instantiatePreset(loadDescriptor(descriptor, context));
validatePreset(preset, context, descriptor);
return (0, _configChain.buildPresetChain)(preset, context);
}; };
const instantiatePreset = (0, _caching.makeWeakCache)(({ const instantiatePreset = (0, _caching.makeWeakCache)(({

View File

@@ -47,9 +47,18 @@ function assertVisitorHandler(key, value) {
} }
function validatePluginObject(obj) { function validatePluginObject(obj) {
const rootPath = {
type: "root",
source: "plugin"
};
Object.keys(obj).forEach(key => { Object.keys(obj).forEach(key => {
const validator = VALIDATORS[key]; const validator = VALIDATORS[key];
if (validator) validator(key, obj[key]);else throw new Error(`.${key} is not a valid Plugin property`); const optLoc = {
type: "option",
name: key,
parent: rootPath
};
if (validator) validator(optLoc, obj[key]);else throw new Error(`.${key} is not a valid Plugin property`);
}); });
return obj; return obj;
} }

View File

@@ -219,7 +219,9 @@ var _transformAst = require("./transform-ast");
var _parse = require("./parse"); var _parse = require("./parse");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@@ -47,7 +47,9 @@ function t() {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const buildUmdWrapper = replacements => _template().default` const buildUmdWrapper = replacements => _template().default`
(function (root, factory) { (function (root, factory) {

View File

@@ -57,7 +57,9 @@ function _semver() {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const errorVisitor = { const errorVisitor = {
enter(path, state) { enter(path, state) {
@@ -232,7 +234,6 @@ class File {
buildCodeFrameError(node, msg, Error = SyntaxError) { buildCodeFrameError(node, msg, Error = SyntaxError) {
let loc = node && (node.loc || node._loc); let loc = node && (node.loc || node._loc);
msg = `${this.opts.filename}: ${msg}`;
if (!loc && node) { if (!loc && node) {
const state = { const state = {
@@ -253,7 +254,11 @@ class File {
start: { start: {
line: loc.start.line, line: loc.start.line,
column: loc.start.column + 1 column: loc.start.column + 1
} },
end: loc.end && loc.start.line === loc.end.line ? {
line: loc.end.line,
column: loc.end.column + 1
} : undefined
}, { }, {
highlightCode highlightCode
}); });

View File

@@ -59,7 +59,7 @@ function generateCode(pluginPasses, file) {
result = results[0]; result = results[0];
if (typeof result.then === "function") { if (typeof result.then === "function") {
throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`);
} }
} else { } else {
throw new Error("More than one plugin attempted to override codegen."); throw new Error("More than one plugin attempted to override codegen.");

View File

@@ -42,12 +42,43 @@ function runAsync(config, code, ast, callback) {
function runSync(config, code, ast) { function runSync(config, code, ast) {
const file = (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast); const file = (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast);
transformFile(file, config.passes);
const opts = file.opts; const opts = file.opts;
const {
outputCode, try {
outputMap transformFile(file, config.passes);
} = opts.code !== false ? (0, _generate.default)(config.passes, file) : {}; } catch (e) {
var _opts$filename;
e.message = `${(_opts$filename = opts.filename) !== null && _opts$filename !== void 0 ? _opts$filename : "unknown"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_TRANSFORM_ERROR";
}
throw e;
}
let outputCode, outputMap;
try {
if (opts.code !== false) {
({
outputCode,
outputMap
} = (0, _generate.default)(config.passes, file));
}
} catch (e) {
var _opts$filename2;
e.message = `${(_opts$filename2 = opts.filename) !== null && _opts$filename2 !== void 0 ? _opts$filename2 : "unknown"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_GENERATE_ERROR";
}
throw e;
}
return { return {
metadata: file.metadata, metadata: file.metadata,
options: opts, options: opts,

View File

@@ -79,7 +79,9 @@ var _file = _interopRequireDefault(require("./file/file"));
var _missingPluginHelper = _interopRequireDefault(require("./util/missing-plugin-helper")); var _missingPluginHelper = _interopRequireDefault(require("./util/missing-plugin-helper"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -87,44 +89,6 @@ const debug = (0, _debug().default)("babel:transform:file");
function normalizeFile(pluginPasses, options, code, ast) { function normalizeFile(pluginPasses, options, code, ast) {
code = `${code || ""}`; code = `${code || ""}`;
let inputMap = null;
if (options.inputSourceMap !== false) {
if (typeof options.inputSourceMap === "object") {
inputMap = _convertSourceMap().default.fromObject(options.inputSourceMap);
}
if (!inputMap) {
try {
inputMap = _convertSourceMap().default.fromSource(code);
if (inputMap) {
code = _convertSourceMap().default.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = _convertSourceMap().default.removeComments(code);
}
}
if (!inputMap) {
if (typeof options.filename === "string") {
try {
inputMap = _convertSourceMap().default.fromMapFileSource(code, _path().default.dirname(options.filename));
if (inputMap) {
code = _convertSourceMap().default.removeMapFileComments(code);
}
} catch (err) {
debug("discarding unknown file input sourcemap", err);
code = _convertSourceMap().default.removeMapFileComments(code);
}
} else {
debug("discarding un-loadable file input sourcemap");
code = _convertSourceMap().default.removeMapFileComments(code);
}
}
}
if (ast) { if (ast) {
if (ast.type === "Program") { if (ast.type === "Program") {
@@ -138,6 +102,40 @@ function normalizeFile(pluginPasses, options, code, ast) {
ast = parser(pluginPasses, options, code); ast = parser(pluginPasses, options, code);
} }
let inputMap = null;
if (options.inputSourceMap !== false) {
if (typeof options.inputSourceMap === "object") {
inputMap = _convertSourceMap().default.fromObject(options.inputSourceMap);
}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = _convertSourceMap().default.fromComment(lastComment);
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
}
}
}
if (!inputMap) {
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
if (typeof options.filename === "string" && lastComment) {
try {
inputMap = _convertSourceMap().default.fromMapFileComment(`//${lastComment}`, _path().default.dirname(options.filename));
} catch (err) {
debug("discarding unknown file input sourcemap", err);
}
} else if (lastComment) {
debug("discarding un-loadable file input sourcemap");
}
}
}
return new _file.default(options, { return new _file.default(options, {
code, code,
ast, ast,
@@ -170,7 +168,7 @@ function parser(pluginPasses, {
return (0, _parser().parse)(code, parserOpts); return (0, _parser().parse)(code, parserOpts);
} else if (results.length === 1) { } else if (results.length === 1) {
if (typeof results[0].then === "function") { if (typeof results[0].then === "function") {
throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
} }
return results[0]; return results[0];
@@ -209,3 +207,33 @@ function parser(pluginPasses, {
throw err; throw err;
} }
} }
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=(?:[^\s'"`]+?)[ \t]*$/;
function extractCommentsFromList(regex, comments, lastComment) {
if (comments) {
comments = comments.filter(({
value
}) => {
if (regex.test(value)) {
lastComment = value;
return false;
}
return true;
});
}
return [comments, lastComment];
}
function extractComments(regex, ast) {
let lastComment = null;
t().traverseFast(ast, node => {
[node.leadingComments, lastComment] = extractCommentsFromList(regex, node.leadingComments, lastComment);
[node.innerComments, lastComment] = extractCommentsFromList(regex, node.innerComments, lastComment);
[node.trailingComments, lastComment] = extractCommentsFromList(regex, node.trailingComments, lastComment);
});
return lastComment;
}

View File

@@ -398,14 +398,15 @@ range, use the `satisfies(version, range)` function.
* `coerce(version)`: Coerces a string to semver if possible * `coerce(version)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver This aims to provide a very forgiving translation of a non-semver string to
string to semver. It looks for the first digit in a string, and semver. It looks for the first digit in a string, and consumes all
consumes all remaining characters which satisfy at least a partial semver remaining characters which satisfy at least a partial semver (e.g., `1`,
(e.g., `1`, `1.2`, `1.2.3`) up to the max permitted length (256 characters). `1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
Longer versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
All surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes `3.4.0`). surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
Only text which lacks digits will fail coercion (`version one` is not valid). `3.4.0`). Only text which lacks digits will fail coercion (`version one`
The maximum length for any semver component considered for coercion is 16 characters; is not valid). The maximum length for any semver component considered for
longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`). coercion is 16 characters; longer components will be ignored
The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; (`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
higher value components are invalid (`9999999999999999.4.7.4` is likely invalid). semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).

View File

@@ -1,39 +1,35 @@
{ {
"_args": [ "_from": "semver@^5.4.1",
[ "_id": "semver@5.7.1",
"semver@5.7.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "semver@5.7.0",
"_id": "semver@5.7.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "_integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"_location": "/@babel/core/semver", "_location": "/@babel/core/semver",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "semver@5.7.0", "raw": "semver@^5.4.1",
"name": "semver", "name": "semver",
"escapedName": "semver", "escapedName": "semver",
"rawSpec": "5.7.0", "rawSpec": "^5.4.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "5.7.0" "fetchSpec": "^5.4.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/core" "/@babel/core"
], ],
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", "_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"_spec": "5.7.0", "_shasum": "a954f931aeba508d307bbf069eff0c01c96116f7",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "semver@^5.4.1",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/core",
"bin": { "bin": {
"semver": "./bin/semver" "semver": "./bin/semver"
}, },
"bugs": { "bugs": {
"url": "https://github.com/npm/node-semver/issues" "url": "https://github.com/npm/node-semver/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "The semantic version parser used by npm.", "description": "The semantic version parser used by npm.",
"devDependencies": { "devDependencies": {
"tap": "^13.0.0-rc.18" "tap": "^13.0.0-rc.18"
@@ -60,5 +56,5 @@
"tap": { "tap": {
"check-coverage": true "check-coverage": true
}, },
"version": "5.7.0" "version": "5.7.1"
} }

View File

@@ -1,35 +1,29 @@
{ {
"_args": [ "_from": "@babel/core@^7.1.0",
[ "_id": "@babel/core@7.7.2",
"@babel/core@7.5.5",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/core@7.5.5",
"_id": "@babel/core@7.5.5",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==", "_integrity": "sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ==",
"_location": "/@babel/core", "_location": "/@babel/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/core@7.5.5", "raw": "@babel/core@^7.1.0",
"name": "@babel/core", "name": "@babel/core",
"escapedName": "@babel%2fcore", "escapedName": "@babel%2fcore",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.5.5", "rawSpec": "^7.1.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.5.5" "fetchSpec": "^7.1.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@jest/transform", "/@jest/transform",
"/jest-config" "/jest-config"
], ],
"_resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.5.tgz", "_resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.2.tgz",
"_spec": "7.5.5", "_shasum": "ea5b99693bcfc058116f42fa1dd54da412b29d91",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/core@^7.1.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@jest/transform",
"author": { "author": {
"name": "Sebastian McKenzie", "name": "Sebastian McKenzie",
"email": "sebmck@gmail.com" "email": "sebmck@gmail.com"
@@ -38,15 +32,16 @@
"./lib/config/files/index.js": "./lib/config/files/index-browser.js", "./lib/config/files/index.js": "./lib/config/files/index-browser.js",
"./lib/transform-file.js": "./lib/transform-file-browser.js" "./lib/transform-file.js": "./lib/transform-file-browser.js"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.5.5", "@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.5.5", "@babel/generator": "^7.7.2",
"@babel/helpers": "^7.5.5", "@babel/helpers": "^7.7.0",
"@babel/parser": "^7.5.5", "@babel/parser": "^7.7.2",
"@babel/template": "^7.4.4", "@babel/template": "^7.7.0",
"@babel/traverse": "^7.5.5", "@babel/traverse": "^7.7.2",
"@babel/types": "^7.5.5", "@babel/types": "^7.7.2",
"convert-source-map": "^1.1.0", "convert-source-map": "^1.7.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"json5": "^2.1.0", "json5": "^2.1.0",
"lodash": "^4.17.13", "lodash": "^4.17.13",
@@ -54,15 +49,15 @@
"semver": "^5.4.1", "semver": "^5.4.1",
"source-map": "^0.5.0" "source-map": "^0.5.0"
}, },
"deprecated": false,
"description": "Babel compiler core.", "description": "Babel compiler core.",
"devDependencies": { "devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.5.5", "@babel/helper-transform-fixture-test-runner": "^7.6.4"
"@babel/register": "^7.5.5"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
}, },
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43", "gitHead": "35f4d1276310bac6fede4a6f86a5c76f951e179e",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"keywords": [ "keywords": [
"6to5", "6to5",
@@ -89,5 +84,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-core" "url": "https://github.com/babel/babel/tree/master/packages/babel-core"
}, },
"version": "7.5.5" "version": "7.7.2"
} }

View File

@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = void 0; exports.default = void 0;
function _trimRight() {
const data = _interopRequireDefault(require("trim-right"));
_trimRight = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const SPACES_RE = /^[ \t]+$/; const SPACES_RE = /^[ \t]+$/;
class Buffer { class Buffer {
@@ -44,7 +31,7 @@ class Buffer {
const map = this._map; const map = this._map;
const result = { const result = {
code: (0, _trimRight().default)(this._buf.join("")), code: this._buf.join("").trimRight(),
map: null, map: null,
rawMappings: map && map.getRawMappings() rawMappings: map && map.getRawMappings()
}; };

View File

@@ -11,20 +11,14 @@ exports.ClassMethod = ClassMethod;
exports.ClassPrivateMethod = ClassPrivateMethod; exports.ClassPrivateMethod = ClassPrivateMethod;
exports._classMethodHead = _classMethodHead; exports._classMethodHead = _classMethodHead;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function ClassDeclaration(node, parent) { function ClassDeclaration(node, parent) {
if (!this.format.decoratorsBeforeExport || !t().isExportDefaultDeclaration(parent) && !t().isExportNamedDeclaration(parent)) { if (!this.format.decoratorsBeforeExport || !t.isExportDefaultDeclaration(parent) && !t.isExportNamedDeclaration(parent)) {
this.printJoin(node.decorators, node); this.printJoin(node.decorators, node);
} }
@@ -84,26 +78,7 @@ function ClassBody(node) {
function ClassProperty(node) { function ClassProperty(node) {
this.printJoin(node.decorators, node); this.printJoin(node.decorators, node);
this.tsPrintClassMemberModifiers(node, true);
if (node.accessibility) {
this.word(node.accessibility);
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
if (node.abstract) {
this.word("abstract");
this.space();
}
if (node.readonly) {
this.word("readonly");
this.space();
}
if (node.computed) { if (node.computed) {
this.token("["); this.token("[");
@@ -170,21 +145,7 @@ function ClassPrivateMethod(node) {
function _classMethodHead(node) { function _classMethodHead(node) {
this.printJoin(node.decorators, node); this.printJoin(node.decorators, node);
this.tsPrintClassMemberModifiers(node, false);
if (node.accessibility) {
this.word(node.accessibility);
this.space();
}
if (node.abstract) {
this.word("abstract");
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
this._methodHead(node); this._methodHead(node);
} }

View File

@@ -25,21 +25,16 @@ exports.BindExpression = BindExpression;
exports.MemberExpression = MemberExpression; exports.MemberExpression = MemberExpression;
exports.MetaProperty = MetaProperty; exports.MetaProperty = MetaProperty;
exports.PrivateName = PrivateName; exports.PrivateName = PrivateName;
exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
exports.AwaitExpression = exports.YieldExpression = void 0; exports.AwaitExpression = exports.YieldExpression = void 0;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var n = _interopRequireWildcard(require("../node")); var n = _interopRequireWildcard(require("../node"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function UnaryExpression(node) { function UnaryExpression(node) {
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") { if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") {
@@ -93,9 +88,9 @@ function NewExpression(node, parent) {
this.space(); this.space();
this.print(node.callee, node); this.print(node.callee, node);
if (this.format.minified && node.arguments.length === 0 && !node.optional && !t().isCallExpression(parent, { if (this.format.minified && node.arguments.length === 0 && !node.optional && !t.isCallExpression(parent, {
callee: node callee: node
}) && !t().isMemberExpression(parent) && !t().isNewExpression(parent)) { }) && !t.isMemberExpression(parent) && !t.isNewExpression(parent)) {
return; return;
} }
@@ -132,13 +127,13 @@ function Decorator(node) {
function OptionalMemberExpression(node) { function OptionalMemberExpression(node) {
this.print(node.object, node); this.print(node.object, node);
if (!node.computed && t().isMemberExpression(node.property)) { if (!node.computed && t.isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property"); throw new TypeError("Got a MemberExpression for MemberExpression property");
} }
let computed = node.computed; let computed = node.computed;
if (t().isLiteral(node.property) && typeof node.property.value === "number") { if (t.isLiteral(node.property) && typeof node.property.value === "number") {
computed = true; computed = true;
} }
@@ -260,13 +255,13 @@ function BindExpression(node) {
function MemberExpression(node) { function MemberExpression(node) {
this.print(node.object, node); this.print(node.object, node);
if (!node.computed && t().isMemberExpression(node.property)) { if (!node.computed && t.isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property"); throw new TypeError("Got a MemberExpression for MemberExpression property");
} }
let computed = node.computed; let computed = node.computed;
if (t().isLiteral(node.property) && typeof node.property.value === "number") { if (t.isLiteral(node.property) && typeof node.property.value === "number") {
computed = true; computed = true;
} }
@@ -290,3 +285,8 @@ function PrivateName(node) {
this.token("#"); this.token("#");
this.print(node.id, node); this.print(node.id, node);
} }
function V8IntrinsicIdentifier(node) {
this.token("%");
this.word(node.name);
}

View File

@@ -20,6 +20,15 @@ exports.DeclareOpaqueType = DeclareOpaqueType;
exports.DeclareVariable = DeclareVariable; exports.DeclareVariable = DeclareVariable;
exports.DeclareExportDeclaration = DeclareExportDeclaration; exports.DeclareExportDeclaration = DeclareExportDeclaration;
exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration; exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
exports.EnumDeclaration = EnumDeclaration;
exports.EnumBooleanBody = EnumBooleanBody;
exports.EnumNumberBody = EnumNumberBody;
exports.EnumStringBody = EnumStringBody;
exports.EnumSymbolBody = EnumSymbolBody;
exports.EnumDefaultedMember = EnumDefaultedMember;
exports.EnumBooleanMember = EnumBooleanMember;
exports.EnumNumberMember = EnumNumberMember;
exports.EnumStringMember = EnumStringMember;
exports.ExistsTypeAnnotation = ExistsTypeAnnotation; exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
exports.FunctionTypeAnnotation = FunctionTypeAnnotation; exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
exports.FunctionTypeParam = FunctionTypeParam; exports.FunctionTypeParam = FunctionTypeParam;
@@ -66,21 +75,15 @@ Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
} }
}); });
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _modules = require("./modules"); var _modules = require("./modules");
var _types2 = require("./types"); var _types2 = require("./types");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function AnyTypeAnnotation() { function AnyTypeAnnotation() {
this.word("any"); this.word("any");
@@ -105,7 +108,7 @@ function NullLiteralTypeAnnotation() {
} }
function DeclareClass(node, parent) { function DeclareClass(node, parent) {
if (!t().isDeclareExportDeclaration(parent)) { if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare"); this.word("declare");
this.space(); this.space();
} }
@@ -117,7 +120,7 @@ function DeclareClass(node, parent) {
} }
function DeclareFunction(node, parent) { function DeclareFunction(node, parent) {
if (!t().isDeclareExportDeclaration(parent)) { if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare"); this.word("declare");
this.space(); this.space();
} }
@@ -180,7 +183,7 @@ function DeclareTypeAlias(node) {
} }
function DeclareOpaqueType(node, parent) { function DeclareOpaqueType(node, parent) {
if (!t().isDeclareExportDeclaration(parent)) { if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare"); this.word("declare");
this.space(); this.space();
} }
@@ -189,7 +192,7 @@ function DeclareOpaqueType(node, parent) {
} }
function DeclareVariable(node, parent) { function DeclareVariable(node, parent) {
if (!t().isDeclareExportDeclaration(parent)) { if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare"); this.word("declare");
this.space(); this.space();
} }
@@ -222,11 +225,112 @@ function DeclareExportAllDeclaration() {
_modules.ExportAllDeclaration.apply(this, arguments); _modules.ExportAllDeclaration.apply(this, arguments);
} }
function EnumDeclaration(node) {
const {
id,
body
} = node;
this.word("enum");
this.space();
this.print(id, node);
this.print(body, node);
}
function enumExplicitType(context, name, hasExplicitType) {
if (hasExplicitType) {
context.space();
context.word("of");
context.space();
context.word(name);
}
context.space();
}
function enumBody(context, node) {
const {
members
} = node;
context.token("{");
context.indent();
context.newline();
for (const member of members) {
context.print(member, node);
context.newline();
}
context.dedent();
context.token("}");
}
function EnumBooleanBody(node) {
const {
explicitType
} = node;
enumExplicitType(this, "boolean", explicitType);
enumBody(this, node);
}
function EnumNumberBody(node) {
const {
explicitType
} = node;
enumExplicitType(this, "number", explicitType);
enumBody(this, node);
}
function EnumStringBody(node) {
const {
explicitType
} = node;
enumExplicitType(this, "string", explicitType);
enumBody(this, node);
}
function EnumSymbolBody(node) {
enumExplicitType(this, "symbol", true);
enumBody(this, node);
}
function EnumDefaultedMember(node) {
const {
id
} = node;
this.print(id, node);
this.token(",");
}
function enumInitializedMember(context, node) {
const {
id,
init
} = node;
context.print(id, node);
context.space();
context.token("=");
context.space();
context.print(init, node);
context.token(",");
}
function EnumBooleanMember(node) {
enumInitializedMember(this, node);
}
function EnumNumberMember(node) {
enumInitializedMember(this, node);
}
function EnumStringMember(node) {
enumInitializedMember(this, node);
}
function FlowExportDeclaration(node) { function FlowExportDeclaration(node) {
if (node.declaration) { if (node.declaration) {
const declar = node.declaration; const declar = node.declaration;
this.print(declar, node); this.print(declar, node);
if (!t().isStatement(declar)) this.semicolon(); if (!t.isStatement(declar)) this.semicolon();
} else { } else {
this.token("{"); this.token("{");

View File

@@ -12,17 +12,11 @@ exports._functionHead = _functionHead;
exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression; exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression; exports.ArrowFunctionExpression = ArrowFunctionExpression;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _params(node) { function _params(node) {
this.print(node.typeParameters, node); this.print(node.typeParameters, node);
@@ -132,7 +126,7 @@ function ArrowFunctionExpression(node) {
const firstParam = node.params[0]; const firstParam = node.params[0];
if (node.params.length === 1 && t().isIdentifier(firstParam) && !hasTypes(node, firstParam)) { if (node.params.length === 1 && t.isIdentifier(firstParam) && !hasTypes(node, firstParam)) {
if (this.format.retainLines && node.loc && node.body.loc && node.loc.start.line < node.body.loc.start.line) { if (this.format.retainLines && node.loc && node.body.loc && node.loc.start.line < node.body.loc.start.line) {
this.token("("); this.token("(");

View File

@@ -14,17 +14,11 @@ exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ImportDeclaration = ImportDeclaration; exports.ImportDeclaration = ImportDeclaration;
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function ImportSpecifier(node) { function ImportSpecifier(node) {
if (node.importKind === "type" || node.importKind === "typeof") { if (node.importKind === "type" || node.importKind === "typeof") {
@@ -87,7 +81,7 @@ function ExportAllDeclaration(node) {
} }
function ExportNamedDeclaration(node) { function ExportNamedDeclaration(node) {
if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node); this.printJoin(node.declaration.decorators, node);
} }
@@ -97,7 +91,7 @@ function ExportNamedDeclaration(node) {
} }
function ExportDefaultDeclaration(node) { function ExportDefaultDeclaration(node) {
if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) {
this.printJoin(node.declaration.decorators, node); this.printJoin(node.declaration.decorators, node);
} }
@@ -112,7 +106,7 @@ function ExportDeclaration(node) {
if (node.declaration) { if (node.declaration) {
const declar = node.declaration; const declar = node.declaration;
this.print(declar, node); this.print(declar, node);
if (!t().isStatement(declar)) this.semicolon(); if (!t.isStatement(declar)) this.semicolon();
} else { } else {
if (node.exportKind === "type") { if (node.exportKind === "type") {
this.word("type"); this.word("type");
@@ -125,7 +119,7 @@ function ExportDeclaration(node) {
while (true) { while (true) {
const first = specifiers[0]; const first = specifiers[0];
if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) { if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
hasSpecial = true; hasSpecial = true;
this.print(specifiers.shift(), node); this.print(specifiers.shift(), node);
@@ -176,7 +170,7 @@ function ImportDeclaration(node) {
while (true) { while (true) {
const first = specifiers[0]; const first = specifiers[0];
if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) { if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
this.print(specifiers.shift(), node); this.print(specifiers.shift(), node);
if (specifiers.length) { if (specifiers.length) {

View File

@@ -18,17 +18,11 @@ exports.VariableDeclaration = VariableDeclaration;
exports.VariableDeclarator = VariableDeclarator; exports.VariableDeclarator = VariableDeclarator;
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = void 0; exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = void 0;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function WithStatement(node) { function WithStatement(node) {
this.word("with"); this.word("with");
@@ -46,7 +40,7 @@ function IfStatement(node) {
this.print(node.test, node); this.print(node.test, node);
this.token(")"); this.token(")");
this.space(); this.space();
const needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent)); const needsBlock = node.alternate && t.isIfStatement(getLastStatement(node.consequent));
if (needsBlock) { if (needsBlock) {
this.token("{"); this.token("{");
@@ -71,7 +65,7 @@ function IfStatement(node) {
} }
function getLastStatement(statement) { function getLastStatement(statement) {
if (!t().isStatement(statement.body)) return statement; if (!t.isStatement(statement.body)) return statement;
return getLastStatement(statement.body); return getLastStatement(statement.body);
} }
@@ -280,7 +274,7 @@ function VariableDeclaration(node, parent) {
this.space(); this.space();
let hasInits = false; let hasInits = false;
if (!t().isFor(parent)) { if (!t.isFor(parent)) {
for (const declar of node.declarations) { for (const declar of node.declarations) {
if (declar.init) { if (declar.init) {
hasInits = true; hasInits = true;
@@ -298,7 +292,7 @@ function VariableDeclaration(node, parent) {
separator separator
}); });
if (t().isFor(parent)) { if (t.isFor(parent)) {
if (parent.left === node || parent.init === node) return; if (parent.left === node || parent.init === node) return;
} }

View File

@@ -20,29 +20,15 @@ exports.PipelineTopicExpression = PipelineTopicExpression;
exports.PipelineBareFunction = PipelineBareFunction; exports.PipelineBareFunction = PipelineBareFunction;
exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference; exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { var _jsesc = _interopRequireDefault(require("jsesc"));
return data;
};
return data;
}
function _jsesc() {
const data = _interopRequireDefault(require("jsesc"));
_jsesc = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function Identifier(node) { function Identifier(node) {
this.exactSource(node.loc, () => { this.exactSource(node.loc, () => {
@@ -93,14 +79,14 @@ function ObjectProperty(node) {
this.print(node.key, node); this.print(node.key, node);
this.token("]"); this.token("]");
} else { } else {
if (t().isAssignmentPattern(node.value) && t().isIdentifier(node.key) && node.key.name === node.value.left.name) { if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
this.print(node.value, node); this.print(node.value, node);
return; return;
} }
this.print(node.key, node); this.print(node.key, node);
if (node.shorthand && t().isIdentifier(node.key) && t().isIdentifier(node.value) && node.key.name === node.value.name) { if (node.shorthand && t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name) {
return; return;
} }
} }
@@ -170,7 +156,7 @@ function StringLiteral(node) {
opts.json = true; opts.json = true;
} }
const val = (0, _jsesc().default)(node.value, opts); const val = (0, _jsesc.default)(node.value, opts);
return this.token(val); return this.token(val);
} }

View File

@@ -17,6 +17,7 @@ exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
exports.TSMethodSignature = TSMethodSignature; exports.TSMethodSignature = TSMethodSignature;
exports.TSIndexSignature = TSIndexSignature; exports.TSIndexSignature = TSIndexSignature;
exports.TSAnyKeyword = TSAnyKeyword; exports.TSAnyKeyword = TSAnyKeyword;
exports.TSBigIntKeyword = TSBigIntKeyword;
exports.TSUnknownKeyword = TSUnknownKeyword; exports.TSUnknownKeyword = TSUnknownKeyword;
exports.TSNumberKeyword = TSNumberKeyword; exports.TSNumberKeyword = TSNumberKeyword;
exports.TSObjectKeyword = TSObjectKeyword; exports.TSObjectKeyword = TSObjectKeyword;
@@ -68,6 +69,7 @@ exports.TSNonNullExpression = TSNonNullExpression;
exports.TSExportAssignment = TSExportAssignment; exports.TSExportAssignment = TSExportAssignment;
exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration; exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase; exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
function TSTypeAnnotation(node) { function TSTypeAnnotation(node) {
this.token(":"); this.token(":");
@@ -139,12 +141,14 @@ function TSQualifiedName(node) {
function TSCallSignatureDeclaration(node) { function TSCallSignatureDeclaration(node) {
this.tsPrintSignatureDeclarationBase(node); this.tsPrintSignatureDeclarationBase(node);
this.token(";");
} }
function TSConstructSignatureDeclaration(node) { function TSConstructSignatureDeclaration(node) {
this.word("new"); this.word("new");
this.space(); this.space();
this.tsPrintSignatureDeclarationBase(node); this.tsPrintSignatureDeclarationBase(node);
this.token(";");
} }
function TSPropertySignature(node) { function TSPropertySignature(node) {
@@ -216,6 +220,10 @@ function TSAnyKeyword() {
this.word("any"); this.word("any");
} }
function TSBigIntKeyword() {
this.word("bigint");
}
function TSUnknownKeyword() { function TSUnknownKeyword() {
this.word("unknown"); this.word("unknown");
} }
@@ -293,11 +301,19 @@ function TSTypeReference(node) {
} }
function TSTypePredicate(node) { function TSTypePredicate(node) {
if (node.asserts) {
this.word("asserts");
this.space();
}
this.print(node.parameterName); this.print(node.parameterName);
this.space();
this.word("is"); if (node.typeAnnotation) {
this.space(); this.space();
this.print(node.typeAnnotation.typeAnnotation); this.word("is");
this.space();
this.print(node.typeAnnotation.typeAnnotation);
}
} }
function TSTypeQuery(node) { function TSTypeQuery(node) {
@@ -713,3 +729,30 @@ function tsPrintSignatureDeclarationBase(node) {
this.token(")"); this.token(")");
this.print(node.typeAnnotation, node); this.print(node.typeAnnotation, node);
} }
function tsPrintClassMemberModifiers(node, isField) {
if (isField && node.declare) {
this.word("declare");
this.space();
}
if (node.accessibility) {
this.word(node.accessibility);
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
if (node.abstract) {
this.word("abstract");
this.space();
}
if (isField && node.readonly) {
this.word("readonly");
this.space();
}
}

View File

@@ -12,17 +12,11 @@ var whitespace = _interopRequireWildcard(require("./whitespace"));
var parens = _interopRequireWildcard(require("./parentheses")); var parens = _interopRequireWildcard(require("./parentheses"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function expandAliases(obj) { function expandAliases(obj) {
const newObj = {}; const newObj = {};
@@ -36,7 +30,7 @@ function expandAliases(obj) {
} }
for (const type of Object.keys(obj)) { for (const type of Object.keys(obj)) {
const aliases = t().FLIPPED_ALIAS_KEYS[type]; const aliases = t.FLIPPED_ALIAS_KEYS[type];
if (aliases) { if (aliases) {
for (const alias of aliases) { for (const alias of aliases) {
@@ -60,11 +54,11 @@ function find(obj, node, parent, printStack) {
} }
function isOrHasCallExpression(node) { function isOrHasCallExpression(node) {
if (t().isCallExpression(node)) { if (t.isCallExpression(node)) {
return true; return true;
} }
if (t().isMemberExpression(node)) { if (t.isMemberExpression(node)) {
return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property); return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property);
} else { } else {
return false; return false;
@@ -74,7 +68,7 @@ function isOrHasCallExpression(node) {
function needsWhitespace(node, parent, type) { function needsWhitespace(node, parent, type) {
if (!node) return 0; if (!node) return 0;
if (t().isExpressionStatement(node)) { if (t.isExpressionStatement(node)) {
node = node.expression; node = node.expression;
} }
@@ -109,9 +103,10 @@ function needsWhitespaceAfter(node, parent) {
function needsParens(node, parent, printStack) { function needsParens(node, parent, printStack) {
if (!parent) return false; if (!parent) return false;
if (t().isNewExpression(parent) && parent.callee === node) { if (t.isNewExpression(parent) && parent.callee === node) {
if (isOrHasCallExpression(node)) return true; if (isOrHasCallExpression(node)) return true;
} }
if (t.isLogicalExpression(node) && parent.operator === "??") return true;
return find(expandedParens, node, parent, printStack); return find(expandedParens, node, parent, printStack);
} }

View File

@@ -25,17 +25,11 @@ exports.OptionalMemberExpression = OptionalMemberExpression;
exports.AssignmentExpression = AssignmentExpression; exports.AssignmentExpression = AssignmentExpression;
exports.NewExpression = NewExpression; exports.NewExpression = NewExpression;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
const PRECEDENCE = { const PRECEDENCE = {
"||": 0, "||": 0,
@@ -64,22 +58,22 @@ const PRECEDENCE = {
"**": 10 "**": 10
}; };
const isClassExtendsClause = (node, parent) => (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node; const isClassExtendsClause = (node, parent) => (t.isClassDeclaration(parent) || t.isClassExpression(parent)) && parent.superClass === node;
function NullableTypeAnnotation(node, parent) { function NullableTypeAnnotation(node, parent) {
return t().isArrayTypeAnnotation(parent); return t.isArrayTypeAnnotation(parent);
} }
function FunctionTypeAnnotation(node, parent) { function FunctionTypeAnnotation(node, parent, printStack) {
return t().isUnionTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isArrayTypeAnnotation(parent); return t.isUnionTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isArrayTypeAnnotation(parent) || t.isTypeAnnotation(parent) && t.isArrowFunctionExpression(printStack[printStack.length - 3]);
} }
function UpdateExpression(node, parent) { function UpdateExpression(node, parent) {
return t().isMemberExpression(parent, { return t.isMemberExpression(parent, {
object: node object: node
}) || t().isCallExpression(parent, { }) || t.isCallExpression(parent, {
callee: node callee: node
}) || t().isNewExpression(parent, { }) || t.isNewExpression(parent, {
callee: node callee: node
}) || isClassExtendsClause(node, parent); }) || isClassExtendsClause(node, parent);
} }
@@ -95,7 +89,7 @@ function DoExpression(node, parent, printStack) {
} }
function Binary(node, parent) { function Binary(node, parent) {
if (node.operator === "**" && t().isBinaryExpression(parent, { if (node.operator === "**" && t.isBinaryExpression(parent, {
operator: "**" operator: "**"
})) { })) {
return parent.left === node; return parent.left === node;
@@ -105,17 +99,17 @@ function Binary(node, parent) {
return true; return true;
} }
if ((t().isCallExpression(parent) || t().isNewExpression(parent)) && parent.callee === node || t().isUnaryLike(parent) || t().isMemberExpression(parent) && parent.object === node || t().isAwaitExpression(parent)) { if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) {
return true; return true;
} }
if (t().isBinary(parent)) { if (t.isBinary(parent)) {
const parentOp = parent.operator; const parentOp = parent.operator;
const parentPos = PRECEDENCE[parentOp]; const parentPos = PRECEDENCE[parentOp];
const nodeOp = node.operator; const nodeOp = node.operator;
const nodePos = PRECEDENCE[nodeOp]; const nodePos = PRECEDENCE[nodeOp];
if (parentPos === nodePos && parent.right === node && !t().isLogicalExpression(parent) || parentPos > nodePos) { if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) {
return true; return true;
} }
} }
@@ -124,7 +118,7 @@ function Binary(node, parent) {
} }
function UnionTypeAnnotation(node, parent) { function UnionTypeAnnotation(node, parent) {
return t().isArrayTypeAnnotation(parent) || t().isNullableTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isUnionTypeAnnotation(parent); return t.isArrayTypeAnnotation(parent) || t.isNullableTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isUnionTypeAnnotation(parent);
} }
function TSAsExpression() { function TSAsExpression() {
@@ -136,15 +130,15 @@ function TSTypeAssertion() {
} }
function TSUnionType(node, parent) { function TSUnionType(node, parent) {
return t().isTSArrayType(parent) || t().isTSOptionalType(parent) || t().isTSIntersectionType(parent) || t().isTSUnionType(parent) || t().isTSRestType(parent); return t.isTSArrayType(parent) || t.isTSOptionalType(parent) || t.isTSIntersectionType(parent) || t.isTSUnionType(parent) || t.isTSRestType(parent);
} }
function BinaryExpression(node, parent) { function BinaryExpression(node, parent) {
return node.operator === "in" && (t().isVariableDeclarator(parent) || t().isFor(parent)); return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
} }
function SequenceExpression(node, parent) { function SequenceExpression(node, parent) {
if (t().isForStatement(parent) || t().isThrowStatement(parent) || t().isReturnStatement(parent) || t().isIfStatement(parent) && parent.test === node || t().isWhileStatement(parent) && parent.test === node || t().isForInStatement(parent) && parent.right === node || t().isSwitchStatement(parent) && parent.discriminant === node || t().isExpressionStatement(parent) && parent.expression === node) { if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
return false; return false;
} }
@@ -152,7 +146,7 @@ function SequenceExpression(node, parent) {
} }
function YieldExpression(node, parent) { function YieldExpression(node, parent) {
return t().isBinary(parent) || t().isUnaryLike(parent) || t().isCallExpression(parent) || t().isMemberExpression(parent) || t().isNewExpression(parent) || t().isAwaitExpression(parent) && t().isYieldExpression(node) || t().isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent); return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isAwaitExpression(parent) && t.isYieldExpression(node) || t.isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent);
} }
function ClassExpression(node, parent, printStack) { function ClassExpression(node, parent, printStack) {
@@ -162,13 +156,13 @@ function ClassExpression(node, parent, printStack) {
} }
function UnaryLike(node, parent) { function UnaryLike(node, parent) {
return t().isMemberExpression(parent, { return t.isMemberExpression(parent, {
object: node object: node
}) || t().isCallExpression(parent, { }) || t.isCallExpression(parent, {
callee: node callee: node
}) || t().isNewExpression(parent, { }) || t.isNewExpression(parent, {
callee: node callee: node
}) || t().isBinaryExpression(parent, { }) || t.isBinaryExpression(parent, {
operator: "**", operator: "**",
left: node left: node
}) || isClassExtendsClause(node, parent); }) || isClassExtendsClause(node, parent);
@@ -181,13 +175,13 @@ function FunctionExpression(node, parent, printStack) {
} }
function ArrowFunctionExpression(node, parent) { function ArrowFunctionExpression(node, parent) {
return t().isExportDeclaration(parent) || ConditionalExpression(node, parent); return t.isExportDeclaration(parent) || ConditionalExpression(node, parent);
} }
function ConditionalExpression(node, parent) { function ConditionalExpression(node, parent) {
if (t().isUnaryLike(parent) || t().isBinary(parent) || t().isConditionalExpression(parent, { if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, {
test: node test: node
}) || t().isAwaitExpression(parent) || t().isOptionalMemberExpression(parent) || t().isTaggedTemplateExpression(parent) || t().isTSTypeAssertion(parent) || t().isTSAsExpression(parent)) { }) || t.isAwaitExpression(parent) || t.isOptionalMemberExpression(parent) || t.isTaggedTemplateExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSAsExpression(parent)) {
return true; return true;
} }
@@ -195,11 +189,11 @@ function ConditionalExpression(node, parent) {
} }
function OptionalMemberExpression(node, parent) { function OptionalMemberExpression(node, parent) {
return t().isCallExpression(parent) || t().isMemberExpression(parent); return t.isCallExpression(parent) || t.isMemberExpression(parent);
} }
function AssignmentExpression(node) { function AssignmentExpression(node) {
if (t().isObjectPattern(node.left)) { if (t.isObjectPattern(node.left)) {
return true; return true;
} else { } else {
return ConditionalExpression(...arguments); return ConditionalExpression(...arguments);
@@ -220,25 +214,25 @@ function isFirstInStatement(printStack, {
let parent = printStack[i]; let parent = printStack[i];
while (i > 0) { while (i > 0) {
if (t().isExpressionStatement(parent, { if (t.isExpressionStatement(parent, {
expression: node expression: node
}) || t().isTaggedTemplateExpression(parent) || considerDefaultExports && t().isExportDefaultDeclaration(parent, { }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, {
declaration: node declaration: node
}) || considerArrow && t().isArrowFunctionExpression(parent, { }) || considerArrow && t.isArrowFunctionExpression(parent, {
body: node body: node
})) { })) {
return true; return true;
} }
if (t().isCallExpression(parent, { if (t.isCallExpression(parent, {
callee: node callee: node
}) || t().isSequenceExpression(parent) && parent.expressions[0] === node || t().isMemberExpression(parent, { }) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isMemberExpression(parent, {
object: node object: node
}) || t().isConditional(parent, { }) || t.isConditional(parent, {
test: node test: node
}) || t().isBinary(parent, { }) || t.isBinary(parent, {
left: node left: node
}) || t().isAssignmentExpression(parent, { }) || t.isAssignmentExpression(parent, {
left: node left: node
})) { })) {
node = parent; node = parent;

View File

@@ -5,31 +5,25 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.list = exports.nodes = void 0; exports.list = exports.nodes = void 0;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function crawl(node, state = {}) { function crawl(node, state = {}) {
if (t().isMemberExpression(node)) { if (t.isMemberExpression(node)) {
crawl(node.object, state); crawl(node.object, state);
if (node.computed) crawl(node.property, state); if (node.computed) crawl(node.property, state);
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) { } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
crawl(node.left, state); crawl(node.left, state);
crawl(node.right, state); crawl(node.right, state);
} else if (t().isCallExpression(node)) { } else if (t.isCallExpression(node)) {
state.hasCall = true; state.hasCall = true;
crawl(node.callee, state); crawl(node.callee, state);
} else if (t().isFunction(node)) { } else if (t.isFunction(node)) {
state.hasFunction = true; state.hasFunction = true;
} else if (t().isIdentifier(node)) { } else if (t.isIdentifier(node)) {
state.hasHelper = state.hasHelper || isHelper(node.callee); state.hasHelper = state.hasHelper || isHelper(node.callee);
} }
@@ -37,21 +31,21 @@ function crawl(node, state = {}) {
} }
function isHelper(node) { function isHelper(node) {
if (t().isMemberExpression(node)) { if (t.isMemberExpression(node)) {
return isHelper(node.object) || isHelper(node.property); return isHelper(node.object) || isHelper(node.property);
} else if (t().isIdentifier(node)) { } else if (t.isIdentifier(node)) {
return node.name === "require" || node.name[0] === "_"; return node.name === "require" || node.name[0] === "_";
} else if (t().isCallExpression(node)) { } else if (t.isCallExpression(node)) {
return isHelper(node.callee); return isHelper(node.callee);
} else if (t().isBinary(node) || t().isAssignmentExpression(node)) { } else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
return t().isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
} else { } else {
return false; return false;
} }
} }
function isType(node) { function isType(node) {
return t().isLiteral(node) || t().isObjectExpression(node) || t().isArrayExpression(node) || t().isIdentifier(node) || t().isMemberExpression(node); return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
} }
const nodes = { const nodes = {
@@ -74,7 +68,7 @@ const nodes = {
}, },
LogicalExpression(node) { LogicalExpression(node) {
if (t().isFunction(node.left) || t().isFunction(node.right)) { if (t.isFunction(node.left) || t.isFunction(node.right)) {
return { return {
after: true after: true
}; };
@@ -90,7 +84,7 @@ const nodes = {
}, },
CallExpression(node) { CallExpression(node) {
if (t().isFunction(node.callee) || isHelper(node)) { if (t.isFunction(node.callee) || isHelper(node)) {
return { return {
before: true, before: true,
after: true after: true
@@ -118,7 +112,7 @@ const nodes = {
}, },
IfStatement(node) { IfStatement(node) {
if (t().isBlockStatement(node.consequent)) { if (t.isBlockStatement(node.consequent)) {
return { return {
before: true, before: true,
after: true after: true
@@ -184,7 +178,7 @@ exports.list = list;
}; };
} }
[type].concat(t().FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { [type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
nodes[type] = function () { nodes[type] = function () {
return amounts; return amounts;
}; };

View File

@@ -5,43 +5,21 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
function _isInteger() { var _isInteger = _interopRequireDefault(require("lodash/isInteger"));
const data = _interopRequireDefault(require("lodash/isInteger"));
_isInteger = function () { var _repeat = _interopRequireDefault(require("lodash/repeat"));
return data;
};
return data;
}
function _repeat() {
const data = _interopRequireDefault(require("lodash/repeat"));
_repeat = function () {
return data;
};
return data;
}
var _buffer = _interopRequireDefault(require("./buffer")); var _buffer = _interopRequireDefault(require("./buffer"));
var n = _interopRequireWildcard(require("./node")); var n = _interopRequireWildcard(require("./node"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var generatorFunctions = _interopRequireWildcard(require("./generators")); var generatorFunctions = _interopRequireWildcard(require("./generators"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -120,7 +98,7 @@ class Printer {
number(str) { number(str) {
this.word(str); this.word(str);
this._endsWithInteger = (0, _isInteger().default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== "."; this._endsWithInteger = (0, _isInteger.default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== ".";
} }
token(str) { token(str) {
@@ -239,7 +217,7 @@ class Printer {
} }
_getIndent() { _getIndent() {
return (0, _repeat().default)(this.format.indent.style, this._indent); return (0, _repeat.default)(this.format.indent.style, this._indent);
} }
startTerminatorless(isLabel = false) { startTerminatorless(isLabel = false) {
@@ -294,7 +272,7 @@ class Printer {
this._printLeadingComments(node); this._printLeadingComments(node);
const loc = t().isProgram(node) || t().isFile(node) ? null : node.loc; const loc = t.isProgram(node) || t.isFile(node) ? null : node.loc;
this.withSource("start", loc, () => { this.withSource("start", loc, () => {
printMethod.call(this, node, parent); printMethod.call(this, node, parent);
}); });
@@ -385,7 +363,7 @@ class Printer {
printBlock(parent) { printBlock(parent) {
const node = parent.body; const node = parent.body;
if (!t().isEmptyStatement(node)) { if (!t.isEmptyStatement(node)) {
this.space(); this.space();
} }
@@ -472,7 +450,7 @@ class Printer {
} }
const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn()); const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn());
val = val.replace(/\n(?!$)/g, `\n${(0, _repeat().default)(" ", indentSize)}`); val = val.replace(/\n(?!$)/g, `\n${(0, _repeat.default)(" ", indentSize)}`);
} }
if (this.endsWith("/")) this._space(); if (this.endsWith("/")) this._space();

View File

@@ -5,15 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
function _sourceMap() { var _sourceMap = _interopRequireDefault(require("source-map"));
const data = _interopRequireDefault(require("source-map"));
_sourceMap = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -27,20 +19,20 @@ class SourceMap {
get() { get() {
if (!this._cachedMap) { if (!this._cachedMap) {
const map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({ const map = this._cachedMap = new _sourceMap.default.SourceMapGenerator({
sourceRoot: this._opts.sourceRoot sourceRoot: this._opts.sourceRoot
}); });
const code = this._code; const code = this._code;
if (typeof code === "string") { if (typeof code === "string") {
map.setSourceContent(this._opts.sourceFileName, code); map.setSourceContent(this._opts.sourceFileName.replace(/\\/g, "/"), code);
} else if (typeof code === "object") { } else if (typeof code === "object") {
Object.keys(code).forEach(sourceFileName => { Object.keys(code).forEach(sourceFileName => {
map.setSourceContent(sourceFileName, code[sourceFileName]); map.setSourceContent(sourceFileName.replace(/\\/g, "/"), code[sourceFileName]);
}); });
} }
this._rawMappings.forEach(map.addMapping, map); this._rawMappings.forEach(mapping => map.addMapping(mapping), map);
} }
return this._cachedMap.toJSON(); return this._cachedMap.toJSON();
@@ -68,7 +60,7 @@ class SourceMap {
line: generatedLine, line: generatedLine,
column: generatedColumn column: generatedColumn
}, },
source: line == null ? undefined : filename || this._opts.sourceFileName, source: line == null ? undefined : (filename || this._opts.sourceFileName).replace(/\\/g, "/"),
original: line == null ? undefined : { original: line == null ? undefined : {
line: line, line: line,
column: column column: column

View File

@@ -1,56 +1,51 @@
{ {
"_args": [ "_from": "@babel/generator@^7.7.2",
[ "_id": "@babel/generator@7.7.2",
"@babel/generator@7.5.5",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/generator@7.5.5",
"_id": "@babel/generator@7.5.5",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==", "_integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==",
"_location": "/@babel/generator", "_location": "/@babel/generator",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/generator@7.5.5", "raw": "@babel/generator@^7.7.2",
"name": "@babel/generator", "name": "@babel/generator",
"escapedName": "@babel%2fgenerator", "escapedName": "@babel%2fgenerator",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.5.5", "rawSpec": "^7.7.2",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.5.5" "fetchSpec": "^7.7.2"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/core", "/@babel/core",
"/@babel/traverse", "/@babel/traverse",
"/istanbul-lib-instrument" "/istanbul-lib-instrument"
], ],
"_resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz", "_resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz",
"_spec": "7.5.5", "_shasum": "2f4852d04131a5e17ea4f6645488b5da66ebf3af",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/generator@^7.7.2",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/core",
"author": { "author": {
"name": "Sebastian McKenzie", "name": "Sebastian McKenzie",
"email": "sebmck@gmail.com" "email": "sebmck@gmail.com"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/types": "^7.5.5", "@babel/types": "^7.7.2",
"jsesc": "^2.5.1", "jsesc": "^2.5.1",
"lodash": "^4.17.13", "lodash": "^4.17.13",
"source-map": "^0.5.0", "source-map": "^0.5.0"
"trim-right": "^1.0.1"
}, },
"deprecated": false,
"description": "Turns an AST into code.", "description": "Turns an AST into code.",
"devDependencies": { "devDependencies": {
"@babel/helper-fixtures": "^7.5.5", "@babel/helper-fixtures": "^7.6.3",
"@babel/parser": "^7.5.5" "@babel/parser": "^7.7.2"
}, },
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43", "gitHead": "35f4d1276310bac6fede4a6f86a5c76f951e179e",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@@ -62,5 +57,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-generator" "url": "https://github.com/babel/babel/tree/master/packages/babel-generator"
}, },
"version": "7.5.5" "version": "7.7.2"
} }

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2014-2018 Sebastian McKenzie and other contributors Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@@ -5,41 +5,19 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = _default; exports.default = _default;
function _helperGetFunctionArity() { var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity"));
const data = _interopRequireDefault(require("@babel/helper-get-function-arity"));
_helperGetFunctionArity = function () { var _template = _interopRequireDefault(require("@babel/template"));
return data;
};
return data; var t = _interopRequireWildcard(require("@babel/types"));
}
function _template() { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
const data = _interopRequireDefault(require("@babel/template"));
_template = function () { function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const buildPropertyMethodAssignmentWrapper = (0, _template().default)(` const buildPropertyMethodAssignmentWrapper = (0, _template.default)(`
(function (FUNCTION_KEY) { (function (FUNCTION_KEY) {
function FUNCTION_ID() { function FUNCTION_ID() {
return FUNCTION_KEY.apply(this, arguments); return FUNCTION_KEY.apply(this, arguments);
@@ -52,7 +30,7 @@ const buildPropertyMethodAssignmentWrapper = (0, _template().default)(`
return FUNCTION_ID; return FUNCTION_ID;
})(FUNCTION) })(FUNCTION)
`); `);
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template().default)(` const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(`
(function (FUNCTION_KEY) { (function (FUNCTION_KEY) {
function* FUNCTION_ID() { function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments); return yield* FUNCTION_KEY.apply(this, arguments);
@@ -77,15 +55,15 @@ const visitor = {
}; };
function getNameFromLiteralId(id) { function getNameFromLiteralId(id) {
if (t().isNullLiteral(id)) { if (t.isNullLiteral(id)) {
return "null"; return "null";
} }
if (t().isRegExpLiteral(id)) { if (t.isRegExpLiteral(id)) {
return `_${id.pattern}_${id.flags}`; return `_${id.pattern}_${id.flags}`;
} }
if (t().isTemplateLiteral(id)) { if (t.isTemplateLiteral(id)) {
return id.quasis.map(quasi => quasi.value.raw).join(""); return id.quasis.map(quasi => quasi.value.raw).join("");
} }
@@ -101,7 +79,7 @@ function wrap(state, method, id, scope) {
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) { if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
scope.rename(id.name); scope.rename(id.name);
} else { } else {
if (!t().isFunction(method)) return; if (!t.isFunction(method)) return;
let build = buildPropertyMethodAssignmentWrapper; let build = buildPropertyMethodAssignmentWrapper;
if (method.generator) { if (method.generator) {
@@ -115,7 +93,7 @@ function wrap(state, method, id, scope) {
}).expression; }).expression;
const params = template.callee.body.body[0].params; const params = template.callee.body.body[0].params;
for (let i = 0, len = (0, _helperGetFunctionArity().default)(method); i < len; i++) { for (let i = 0, len = (0, _helperGetFunctionArity.default)(method); i < len; i++) {
params.push(scope.generateUidIdentifier("x")); params.push(scope.generateUidIdentifier("x"));
} }
@@ -156,23 +134,23 @@ function _default({
}, localBinding = false) { }, localBinding = false) {
if (node.id) return; if (node.id) return;
if ((t().isObjectProperty(parent) || t().isObjectMethod(parent, { if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, {
kind: "method" kind: "method"
})) && (!parent.computed || t().isLiteral(parent.key))) { })) && (!parent.computed || t.isLiteral(parent.key))) {
id = parent.key; id = parent.key;
} else if (t().isVariableDeclarator(parent)) { } else if (t.isVariableDeclarator(parent)) {
id = parent.id; id = parent.id;
if (t().isIdentifier(id) && !localBinding) { if (t.isIdentifier(id) && !localBinding) {
const binding = scope.parent.getBinding(id.name); const binding = scope.parent.getBinding(id.name);
if (binding && binding.constant && scope.getBinding(id.name) === binding) { if (binding && binding.constant && scope.getBinding(id.name) === binding) {
node.id = t().cloneNode(id); node.id = t.cloneNode(id);
node.id[t().NOT_LOCAL_BINDING] = true; node.id[t.NOT_LOCAL_BINDING] = true;
return; return;
} }
} }
} else if (t().isAssignmentExpression(parent)) { } else if (t.isAssignmentExpression(parent)) {
id = parent.left; id = parent.left;
} else if (!id) { } else if (!id) {
return; return;
@@ -180,9 +158,9 @@ function _default({
let name; let name;
if (id && t().isLiteral(id)) { if (id && t.isLiteral(id)) {
name = getNameFromLiteralId(id); name = getNameFromLiteralId(id);
} else if (id && t().isIdentifier(id)) { } else if (id && t.isIdentifier(id)) {
name = id.name; name = id.name;
} }
@@ -190,9 +168,9 @@ function _default({
return; return;
} }
name = t().toBindingIdentifierName(name); name = t.toBindingIdentifierName(name);
id = t().identifier(name); id = t.identifier(name);
id[t().NOT_LOCAL_BINDING] = true; id[t.NOT_LOCAL_BINDING] = true;
const state = visit(node, name, scope); const state = visit(node, name, scope);
return wrap(state, node, id, scope) || node; return wrap(state, node, id, scope) || node;
} }

View File

@@ -1,40 +1,37 @@
{ {
"_args": [ "_from": "@babel/helper-function-name@^7.7.0",
[ "_id": "@babel/helper-function-name@7.7.0",
"@babel/helper-function-name@7.1.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/helper-function-name@7.1.0",
"_id": "@babel/helper-function-name@7.1.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", "_integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==",
"_location": "/@babel/helper-function-name", "_location": "/@babel/helper-function-name",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/helper-function-name@7.1.0", "raw": "@babel/helper-function-name@^7.7.0",
"name": "@babel/helper-function-name", "name": "@babel/helper-function-name",
"escapedName": "@babel%2fhelper-function-name", "escapedName": "@babel%2fhelper-function-name",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.1.0", "rawSpec": "^7.7.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.1.0" "fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/traverse" "/@babel/traverse"
], ],
"_resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", "_resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz",
"_spec": "7.1.0", "_shasum": "44a5ad151cfff8ed2599c91682dda2ec2c8430a3",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/helper-function-name@^7.7.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/traverse",
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/helper-get-function-arity": "^7.0.0", "@babel/helper-get-function-arity": "^7.7.0",
"@babel/template": "^7.1.0", "@babel/template": "^7.7.0",
"@babel/types": "^7.0.0" "@babel/types": "^7.7.0"
}, },
"deprecated": false,
"description": "Helper function to change the property 'name' of every function", "description": "Helper function to change the property 'name' of every function",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
"name": "@babel/helper-function-name", "name": "@babel/helper-function-name",
@@ -45,5 +42,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name" "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name"
}, },
"version": "7.1.0" "version": "7.7.0"
} }

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com> Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = _default; exports.default = _default;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _default(node) { function _default(node) {
const params = node.params; const params = node.params;
@@ -23,7 +17,7 @@ function _default(node) {
for (let i = 0; i < params.length; i++) { for (let i = 0; i < params.length; i++) {
const param = params[i]; const param = params[i];
if (t().isAssignmentPattern(param) || t().isRestElement(param)) { if (t.isAssignmentPattern(param) || t.isRestElement(param)) {
return i; return i;
} }
} }

View File

@@ -1,44 +1,44 @@
{ {
"_args": [ "_from": "@babel/helper-get-function-arity@^7.7.0",
[ "_id": "@babel/helper-get-function-arity@7.7.0",
"@babel/helper-get-function-arity@7.0.0",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/helper-get-function-arity@7.0.0",
"_id": "@babel/helper-get-function-arity@7.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", "_integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==",
"_location": "/@babel/helper-get-function-arity", "_location": "/@babel/helper-get-function-arity",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/helper-get-function-arity@7.0.0", "raw": "@babel/helper-get-function-arity@^7.7.0",
"name": "@babel/helper-get-function-arity", "name": "@babel/helper-get-function-arity",
"escapedName": "@babel%2fhelper-get-function-arity", "escapedName": "@babel%2fhelper-get-function-arity",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.0.0", "rawSpec": "^7.7.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.0.0" "fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/helper-function-name" "/@babel/helper-function-name"
], ],
"_resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", "_resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz",
"_spec": "7.0.0", "_shasum": "c604886bc97287a1d1398092bc666bc3d7d7aa2d",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/helper-get-function-arity@^7.7.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/helper-function-name",
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/types": "^7.0.0" "@babel/types": "^7.7.0"
}, },
"deprecated": false,
"description": "Helper function to get function arity", "description": "Helper function to get function arity",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
"name": "@babel/helper-get-function-arity", "name": "@babel/helper-get-function-arity",
"publishConfig": {
"access": "public"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity" "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity"
}, },
"version": "7.0.0" "version": "7.7.0"
} }

View File

@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = splitExportDeclaration; exports.default = splitExportDeclaration;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function splitExportDeclaration(exportDeclaration) { function splitExportDeclaration(exportDeclaration) {
if (!exportDeclaration.isExportDeclaration()) { if (!exportDeclaration.isExportDeclaration()) {
@@ -37,12 +31,12 @@ function splitExportDeclaration(exportDeclaration) {
id = scope.generateUidIdentifier("default"); id = scope.generateUidIdentifier("default");
if (standaloneDeclaration || declaration.isFunctionExpression() || declaration.isClassExpression()) { if (standaloneDeclaration || declaration.isFunctionExpression() || declaration.isClassExpression()) {
declaration.node.id = t().cloneNode(id); declaration.node.id = t.cloneNode(id);
} }
} }
const updatedDeclaration = standaloneDeclaration ? declaration : t().variableDeclaration("var", [t().variableDeclarator(t().cloneNode(id), declaration.node)]); const updatedDeclaration = standaloneDeclaration ? declaration : t.variableDeclaration("var", [t.variableDeclarator(t.cloneNode(id), declaration.node)]);
const updatedExportDeclaration = t().exportNamedDeclaration(null, [t().exportSpecifier(t().cloneNode(id), t().identifier("default"))]); const updatedExportDeclaration = t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.identifier("default"))]);
exportDeclaration.insertAfter(updatedExportDeclaration); exportDeclaration.insertAfter(updatedExportDeclaration);
exportDeclaration.replaceWith(updatedDeclaration); exportDeclaration.replaceWith(updatedDeclaration);
@@ -59,9 +53,9 @@ function splitExportDeclaration(exportDeclaration) {
const bindingIdentifiers = declaration.getOuterBindingIdentifiers(); const bindingIdentifiers = declaration.getOuterBindingIdentifiers();
const specifiers = Object.keys(bindingIdentifiers).map(name => { const specifiers = Object.keys(bindingIdentifiers).map(name => {
return t().exportSpecifier(t().identifier(name), t().identifier(name)); return t.exportSpecifier(t.identifier(name), t.identifier(name));
}); });
const aliasDeclar = t().exportNamedDeclaration(null, specifiers); const aliasDeclar = t.exportNamedDeclaration(null, specifiers);
exportDeclaration.insertAfter(aliasDeclar); exportDeclaration.insertAfter(aliasDeclar);
exportDeclaration.replaceWith(declaration.node); exportDeclaration.replaceWith(declaration.node);
return exportDeclaration; return exportDeclaration;

View File

@@ -1,39 +1,35 @@
{ {
"_args": [ "_from": "@babel/helper-split-export-declaration@^7.7.0",
[ "_id": "@babel/helper-split-export-declaration@7.7.0",
"@babel/helper-split-export-declaration@7.4.4",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/helper-split-export-declaration@7.4.4",
"_id": "@babel/helper-split-export-declaration@7.4.4",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", "_integrity": "sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA==",
"_location": "/@babel/helper-split-export-declaration", "_location": "/@babel/helper-split-export-declaration",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/helper-split-export-declaration@7.4.4", "raw": "@babel/helper-split-export-declaration@^7.7.0",
"name": "@babel/helper-split-export-declaration", "name": "@babel/helper-split-export-declaration",
"escapedName": "@babel%2fhelper-split-export-declaration", "escapedName": "@babel%2fhelper-split-export-declaration",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.4.4", "rawSpec": "^7.7.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.4.4" "fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/traverse" "/@babel/traverse"
], ],
"_resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", "_resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz",
"_spec": "7.4.4", "_shasum": "1365e74ea6c614deeb56ebffabd71006a0eb2300",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/helper-split-export-declaration@^7.7.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/traverse",
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/types": "^7.4.4" "@babel/types": "^7.7.0"
}, },
"deprecated": false,
"description": ">", "description": ">",
"gitHead": "2c88694388831b1e5b88e4bbed6781eb2be1edba", "gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
"name": "@babel/helper-split-export-declaration", "name": "@babel/helper-split-export-declaration",
@@ -44,5 +40,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-split-export-declaration" "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-split-export-declaration"
}, },
"version": "7.4.4" "version": "7.7.0"
} }

View File

@@ -5,15 +5,7 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
function _template() { var _template = _interopRequireDefault(require("@babel/template"));
const data = _interopRequireDefault(require("@babel/template"));
_template = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -23,7 +15,7 @@ exports.default = _default;
const helper = minVersion => tpl => ({ const helper = minVersion => tpl => ({
minVersion, minVersion,
ast: () => _template().default.program.ast(tpl) ast: () => _template.default.program.ast(tpl)
}); });
helpers.typeof = helper("7.0.0-beta.0")` helpers.typeof = helper("7.0.0-beta.0")`
@@ -61,15 +53,6 @@ helpers.jsx = helper("7.0.0-beta.0")`
children: void 0, children: void 0,
}; };
} }
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
if (childrenLength === 1) { if (childrenLength === 1) {
props.children = children; props.children = children;
@@ -81,6 +64,16 @@ helpers.jsx = helper("7.0.0-beta.0")`
props.children = childArray; props.children = childArray;
} }
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
return { return {
$$typeof: REACT_ELEMENT_TYPE, $$typeof: REACT_ELEMENT_TYPE,
type: type, type: type,
@@ -146,7 +139,7 @@ helpers.AsyncGenerator = helper("7.0.0-beta.0")`
Promise.resolve(wrappedAwait ? value.wrapped : value).then( Promise.resolve(wrappedAwait ? value.wrapped : value).then(
function (arg) { function (arg) {
if (wrappedAwait) { if (wrappedAwait) {
resume("next", arg); resume(key === "return" ? "return" : "next", arg);
return return
} }
@@ -245,6 +238,10 @@ helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")`
if (typeof inner.return === "function") { if (typeof inner.return === "function") {
iter.return = function (value) { iter.return = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value); return pump("return", value);
}; };
} }
@@ -593,28 +590,47 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
} }
`; `;
helpers.interopRequireWildcard = helper("7.0.0-beta.0")` helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () { return cache; };
return cache;
}
export default function _interopRequireWildcard(obj) { export default function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) { if (obj && obj.__esModule) {
return obj; return obj;
} else { }
var newObj = {};
if (obj != null) { if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
for (var key in obj) { return { default: obj }
if (Object.prototype.hasOwnProperty.call(obj, key)) { }
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key) var cache = _getRequireWildcardCache();
: {}; if (cache && cache.has(obj)) {
if (desc.get || desc.set) { return cache.get(obj);
Object.defineProperty(newObj, key, desc); }
} else {
newObj[key] = obj[key]; var newObj = {};
} var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
} for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
} }
} }
newObj.default = obj;
return newObj;
} }
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
} }
`; `;
helpers.newArrowCheck = helper("7.0.0-beta.0")` helpers.newArrowCheck = helper("7.0.0-beta.0")`
@@ -792,17 +808,6 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
return strings; return strings;
} }
`; `;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
export default function _temporalRef(val, name) {
if (val === undef) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
} else {
return val;
}
}
`;
helpers.readOnlyError = helper("7.0.0-beta.0")` helpers.readOnlyError = helper("7.0.0-beta.0")`
export default function _readOnlyError(name) { export default function _readOnlyError(name) {
throw new Error("\\"" + name + "\\" is read-only"); throw new Error("\\"" + name + "\\" is read-only");
@@ -814,7 +819,22 @@ helpers.classNameTDZError = helper("7.0.0-beta.0")`
} }
`; `;
helpers.temporalUndefined = helper("7.0.0-beta.0")` helpers.temporalUndefined = helper("7.0.0-beta.0")`
export default {}; // This function isn't mean to be called, but to be used as a reference.
// We can't use a normal object because it isn't hoisted.
export default function _temporalUndefined() {}
`;
helpers.tdz = helper("7.5.5")`
export default function _tdzError(name) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
}
`;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
import err from "tdz";
export default function _temporalRef(val, name) {
return val === undef ? err(name) : val;
}
`; `;
helpers.slicedToArray = helper("7.0.0-beta.0")` helpers.slicedToArray = helper("7.0.0-beta.0")`
import arrayWithHoles from "arrayWithHoles"; import arrayWithHoles from "arrayWithHoles";
@@ -877,14 +897,16 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
export default function _iterableToArrayLimit(arr, i) { export default function _iterableToArrayLimit(arr, i) {
// this is an expanded form of \`for...of\` that properly supports abrupt completions of // this is an expanded form of \`for...of\` that properly supports abrupt completions of
// iterators etc. variable names have been minimised to reduce the size of this massive // iterators etc. variable names have been minimised to reduce the size of this massive
// helper. sometimes spec compliancy is annoying :( // helper. sometimes spec compliance is annoying :(
// //
// _n = _iteratorNormalCompletion // _n = _iteratorNormalCompletion
// _d = _didIteratorError // _d = _didIteratorError
// _e = _iteratorError // _e = _iteratorError
// _i = _iterator // _i = _iterator
// _s = _step // _s = _step
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = []; var _arr = [];
var _n = true; var _n = true;
var _d = false; var _d = false;
@@ -909,6 +931,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
`; `;
helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")` helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
export default function _iterableToArrayLimitLoose(arr, i) { export default function _iterableToArrayLimitLoose(arr, i) {
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = []; var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value); _arr.push(_step.value);
@@ -963,9 +988,7 @@ helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
export default function _initializerWarningHelper(descriptor, context){ export default function _initializerWarningHelper(descriptor, context){
throw new Error( throw new Error(
'Decorating class property failed. Please ensure that ' + 'Decorating class property failed. Please ensure that ' +
'proposal-class-properties is enabled and set to use loose mode. ' + 'proposal-class-properties is enabled and runs after the decorators transform.'
'To use proposal-class-properties in spec mode with decorators, wait for ' +
'the next major version of decorators in stage 2.'
); );
} }
`; `;
@@ -1092,6 +1115,9 @@ helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
if (receiver !== classConstructor) { if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance"); throw new TypeError("Private static access of wrong provenance");
} }
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value; return descriptor.value;
} }
`; `;
@@ -1100,13 +1126,18 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
if (receiver !== classConstructor) { if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance"); throw new TypeError("Private static access of wrong provenance");
} }
if (!descriptor.writable) { if (descriptor.set) {
// This should only throw in strict mode, but class bodies are descriptor.set.call(receiver, value);
// always strict and private fields can only be used inside } else {
// class bodies. if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field"); // This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
} }
descriptor.value = value;
return value; return value;
} }
`; `;
@@ -1817,16 +1848,17 @@ helpers.wrapRegExp = helper("7.2.6")`
export default function _wrapRegExp(re, groups) { export default function _wrapRegExp(re, groups) {
_wrapRegExp = function(re, groups) { _wrapRegExp = function(re, groups) {
return new BabelRegExp(re, groups); return new BabelRegExp(re, undefined, groups);
}; };
var _RegExp = wrapNativeSuper(RegExp); var _RegExp = wrapNativeSuper(RegExp);
var _super = RegExp.prototype; var _super = RegExp.prototype;
var _groups = new WeakMap(); var _groups = new WeakMap();
function BabelRegExp(re, groups) { function BabelRegExp(re, flags, groups) {
var _this = _RegExp.call(this, re); var _this = _RegExp.call(this, re, flags);
_groups.set(_this, groups); // if the regex is recreated with 'g' flag
_groups.set(_this, groups || _groups.get(re));
return _this; return _this;
} }
inherits(BabelRegExp, _RegExp); inherits(BabelRegExp, _RegExp);

View File

@@ -9,29 +9,15 @@ exports.getDependencies = getDependencies;
exports.ensure = ensure; exports.ensure = ensure;
exports.default = exports.list = void 0; exports.default = exports.list = void 0;
function _traverse() { var _traverse = _interopRequireDefault(require("@babel/traverse"));
const data = _interopRequireDefault(require("@babel/traverse"));
_traverse = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _helpers = _interopRequireDefault(require("./helpers")); var _helpers = _interopRequireDefault(require("./helpers"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -55,7 +41,7 @@ function getHelperMetadata(file) {
const exportBindingAssignments = []; const exportBindingAssignments = [];
const importPaths = []; const importPaths = [];
const importBindingsReferences = []; const importBindingsReferences = [];
(0, _traverse().default)(file, { (0, _traverse.default)(file, {
ImportDeclaration(child) { ImportDeclaration(child) {
const name = child.node.source.value; const name = child.node.source.value;
@@ -100,7 +86,7 @@ function getHelperMetadata(file) {
} }
}); });
(0, _traverse().default)(file, { (0, _traverse.default)(file, {
Program(path) { Program(path) {
const bindings = path.scope.getAllBindings(); const bindings = path.scope.getAllBindings();
Object.keys(bindings).forEach(name => { Object.keys(bindings).forEach(name => {
@@ -184,7 +170,7 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
toRename[exportName] = id.name; toRename[exportName] = id.name;
} }
(0, _traverse().default)(file, { (0, _traverse.default)(file, {
Program(path) { Program(path) {
const exp = path.get(exportPath); const exp = path.get(exportPath);
const imps = importPaths.map(p => path.get(p)); const imps = importPaths.map(p => path.get(p));
@@ -195,18 +181,18 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
if (decl.isFunctionDeclaration()) { if (decl.isFunctionDeclaration()) {
exp.replaceWith(decl); exp.replaceWith(decl);
} else { } else {
exp.replaceWith(t().variableDeclaration("var", [t().variableDeclarator(id, decl.node)])); exp.replaceWith(t.variableDeclaration("var", [t.variableDeclarator(id, decl.node)]));
} }
} else if (id.type === "MemberExpression") { } else if (id.type === "MemberExpression") {
if (decl.isFunctionDeclaration()) { if (decl.isFunctionDeclaration()) {
exportBindingAssignments.forEach(assignPath => { exportBindingAssignments.forEach(assignPath => {
const assign = path.get(assignPath); const assign = path.get(assignPath);
assign.replaceWith(t().assignmentExpression("=", id, assign.node)); assign.replaceWith(t.assignmentExpression("=", id, assign.node));
}); });
exp.replaceWith(decl); exp.replaceWith(decl);
path.pushContainer("body", t().expressionStatement(t().assignmentExpression("=", id, t().identifier(exportName)))); path.pushContainer("body", t.expressionStatement(t.assignmentExpression("=", id, t.identifier(exportName))));
} else { } else {
exp.replaceWith(t().expressionStatement(t().assignmentExpression("=", id, decl.node))); exp.replaceWith(t.expressionStatement(t.assignmentExpression("=", id, decl.node)));
} }
} else { } else {
throw new Error("Unexpected helper format."); throw new Error("Unexpected helper format.");
@@ -219,7 +205,7 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
for (const path of imps) path.remove(); for (const path of imps) path.remove();
for (const path of impsBindingRefs) { for (const path of impsBindingRefs) {
const node = t().cloneNode(dependenciesRefs[path.node.name]); const node = t.cloneNode(dependenciesRefs[path.node.name]);
path.replaceWith(node); path.replaceWith(node);
} }
@@ -243,7 +229,7 @@ function loadHelper(name) {
} }
const fn = () => { const fn = () => {
return t().file(helper.ast()); return t.file(helper.ast());
}; };
const metadata = getHelperMetadata(fn()); const metadata = getHelperMetadata(fn());

View File

@@ -1,48 +1,44 @@
{ {
"_args": [ "_from": "@babel/helpers@^7.7.0",
[ "_id": "@babel/helpers@7.7.0",
"@babel/helpers@7.5.5",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/helpers@7.5.5",
"_id": "@babel/helpers@7.5.5",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==", "_integrity": "sha512-VnNwL4YOhbejHb7x/b5F39Zdg5vIQpUUNzJwx0ww1EcVRt41bbGRZWhAURrfY32T5zTT3qwNOQFWpn+P0i0a2g==",
"_location": "/@babel/helpers", "_location": "/@babel/helpers",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/helpers@7.5.5", "raw": "@babel/helpers@^7.7.0",
"name": "@babel/helpers", "name": "@babel/helpers",
"escapedName": "@babel%2fhelpers", "escapedName": "@babel%2fhelpers",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.5.5", "rawSpec": "^7.7.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.5.5" "fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/core" "/@babel/core"
], ],
"_resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.5.tgz", "_resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.7.0.tgz",
"_spec": "7.5.5", "_shasum": "359bb5ac3b4726f7c1fde0ec75f64b3f4275d60b",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/helpers@^7.7.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/core",
"author": { "author": {
"name": "Sebastian McKenzie", "name": "Sebastian McKenzie",
"email": "sebmck@gmail.com" "email": "sebmck@gmail.com"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/template": "^7.4.4", "@babel/template": "^7.7.0",
"@babel/traverse": "^7.5.5", "@babel/traverse": "^7.7.0",
"@babel/types": "^7.5.5" "@babel/types": "^7.7.0"
}, },
"deprecated": false,
"description": "Collection of helper functions used by Babel transforms.", "description": "Collection of helper functions used by Babel transforms.",
"devDependencies": { "devDependencies": {
"@babel/helper-plugin-test-runner": "^7.0.0" "@babel/helper-plugin-test-runner": "^7.0.0"
}, },
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43", "gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@@ -54,5 +50,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helpers" "url": "https://github.com/babel/babel/tree/master/packages/babel-helpers"
}, },
"version": "7.5.5" "version": "7.7.0"
} }

View File

@@ -2,7 +2,7 @@
> **Tags:** > **Tags:**
> - :boom: [Breaking Change] > - :boom: [Breaking Change]
> - :eyeglasses: [Spec Compliancy] > - :eyeglasses: [Spec Compliance]
> - :rocket: [New Feature] > - :rocket: [New Feature]
> - :bug: [Bug Fix] > - :bug: [Bug Fix]
> - :memo: [Documentation] > - :memo: [Documentation]
@@ -56,7 +56,7 @@ See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.m
## 7.0.0-beta.7 (2017-03-22) ## 7.0.0-beta.7 (2017-03-22)
### Spec Compliancy ### Spec Compliance
* Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu) * Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu)
### Bug Fix ### Bug Fix
@@ -200,7 +200,7 @@ declare module "C" {
} }
``` ```
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons) Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
@@ -305,7 +305,7 @@ AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon
## 6.15.0 (2017-01-10) ## 6.15.0 (2017-01-10)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison) Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
@@ -411,7 +411,7 @@ Will include all parser plugins instead of specifying each one individually. Use
## 6.14.0 (2016-11-16) ## 6.14.0 (2016-11-16)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo) Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
@@ -491,7 +491,7 @@ With that test case, there was a ~95ms savings by removing the need for node to
## v6.13.0 (2016-10-21) ## v6.13.0 (2016-10-21)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman) Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
@@ -549,7 +549,7 @@ Fixes two tests that are failing after the merge of #172 ([#177](https://github.
## v6.12.0 (2016-10-14) ## v6.12.0 (2016-10-14)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler) Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)
@@ -643,7 +643,7 @@ export const { foo: [ ,, qux7 ] } = bar;
## v6.11.5 (2016-10-12) ## v6.11.5 (2016-10-12)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo) Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo)
@@ -689,7 +689,7 @@ Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu)
## v6.11.3 (2016-10-01) ## v6.11.3 (2016-10-01)
### :eyeglasses: Spec Compliancy ### :eyeglasses: Spec Compliance
Add static errors for object rest (#149) ([@danez](https://github.com/danez)) Add static errors for object rest (#149) ([@danez](https://github.com/danez))
@@ -782,7 +782,7 @@ export toString from './toString';
## 6.11.0 (2016-09-22) ## 6.11.0 (2016-09-22)
### Spec Compliancy (will break CI) ### Spec Compliance (will break CI)
- Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo - Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo
@@ -862,9 +862,9 @@ for (+i in {});
## 6.10.0 (2016-09-19) ## 6.10.0 (2016-09-19)
> We plan to include some spec compliancy bugs in patch versions. An example was the multiple default exports issue. > We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue.
### Spec Compliancy ### Spec Compliance
* Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu) * Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu)
@@ -1023,7 +1023,7 @@ declare module "foo" {
- The existential type `*` is not a valid type parameter. - The existential type `*` is not a valid type parameter.
- The existential type `*` is a primary type - The existential type `*` is a primary type
### Spec Compliancy ### Spec Compliance
- The param list for type parameter declarations now consists of `TypeParameter` nodes - The param list for type parameter declarations now consists of `TypeParameter` nodes
- New `TypeParameter` AST Node (replaces using the `Identifier` node before) - New `TypeParameter` AST Node (replaces using the `Identifier` node before)

2056
node_modules/@babel/parser/lib/index.js generated vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +1,20 @@
{ {
"_args": [ "_from": "@babel/parser@^7.7.2",
[ "_id": "@babel/parser@7.7.3",
"@babel/parser@7.5.5",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/parser@7.5.5",
"_id": "@babel/parser@7.5.5",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", "_integrity": "sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A==",
"_location": "/@babel/parser", "_location": "/@babel/parser",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/parser@7.5.5", "raw": "@babel/parser@^7.7.2",
"name": "@babel/parser", "name": "@babel/parser",
"escapedName": "@babel%2fparser", "escapedName": "@babel%2fparser",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.5.5", "rawSpec": "^7.7.2",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.5.5" "fetchSpec": "^7.7.2"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/core", "/@babel/core",
@@ -31,9 +24,10 @@
"/@types/babel__template", "/@types/babel__template",
"/istanbul-lib-instrument" "/istanbul-lib-instrument"
], ],
"_resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", "_resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.3.tgz",
"_spec": "7.5.5", "_shasum": "5fad457c2529de476a248f75b0f090b3060af043",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/parser@^7.7.2",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/core",
"author": { "author": {
"name": "Sebastian McKenzie", "name": "Sebastian McKenzie",
"email": "sebmck@gmail.com" "email": "sebmck@gmail.com"
@@ -41,10 +35,12 @@
"bin": { "bin": {
"parser": "./bin/babel-parser.js" "parser": "./bin/babel-parser.js"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "A JavaScript parser", "description": "A JavaScript parser",
"devDependencies": { "devDependencies": {
"@babel/code-frame": "^7.5.5", "@babel/code-frame": "^7.5.5",
"@babel/helper-fixtures": "^7.5.5", "@babel/helper-fixtures": "^7.6.3",
"charcodes": "^0.2.0", "charcodes": "^0.2.0",
"unicode-12.0.0": "^0.7.9" "unicode-12.0.0": "^0.7.9"
}, },
@@ -56,7 +52,7 @@
"lib", "lib",
"typings" "typings"
], ],
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43", "gitHead": "e315d65a7a8cedbe0476b4a2872890e93a1289ba",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"keywords": [ "keywords": [
"babel", "babel",
@@ -70,12 +66,12 @@
"main": "lib/index.js", "main": "lib/index.js",
"name": "@babel/parser", "name": "@babel/parser",
"publishConfig": { "publishConfig": {
"tag": "next" "access": "public"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-parser" "url": "https://github.com/babel/babel/tree/master/packages/babel-parser"
}, },
"types": "typings/babel-parser.d.ts", "types": "typings/babel-parser.d.ts",
"version": "7.5.5" "version": "7.7.3"
} }

View File

@@ -36,6 +36,12 @@ export interface ParserOptions {
allowSuperOutsideMethod?: boolean; allowSuperOutsideMethod?: boolean;
/**
* By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables.
*/
allowUndeclaredExports?: boolean;
/** /**
* Indicate the mode the code should be parsed in. * Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script". * Can be one of "script", "module", or "unambiguous". Defaults to "script".
@@ -89,32 +95,37 @@ export interface ParserOptions {
} }
export type ParserPlugin = export type ParserPlugin =
'estree' | 'asyncGenerators' |
'jsx' | 'bigInt' |
'flow' | 'classPrivateMethods' |
'flowComments' | 'classPrivateProperties' |
'typescript' | 'classProperties' |
'doExpressions' |
'objectRestSpread' |
'decorators' | 'decorators' |
'decorators-legacy' | 'decorators-legacy' |
'classProperties' | 'doExpressions' |
'classPrivateProperties' | 'dynamicImport' |
'classPrivateMethods' | 'estree' |
'exportDefaultFrom' | 'exportDefaultFrom' |
'exportNamespaceFrom' | 'exportNamespaceFrom' | // deprecated
'asyncGenerators' | 'flow' |
'flowComments' |
'functionBind' | 'functionBind' |
'functionSent' | 'functionSent' |
'dynamicImport' |
'numericSeparator' |
'optionalChaining' |
'importMeta' | 'importMeta' |
'bigInt' | 'jsx' |
'optionalCatchBinding' | 'logicalAssignment' |
'throwExpressions' |
'pipelineOperator' |
'nullishCoalescingOperator' | 'nullishCoalescingOperator' |
'numericSeparator' |
'objectRestSpread' |
'optionalCatchBinding' |
'optionalChaining' |
'partialApplication' |
'pipelineOperator' |
'placeholders' |
'throwExpressions' |
'topLevelAwait' |
'typescript' |
'v8intrinsic' |
ParserPluginWithOptions; ParserPluginWithOptions;
export type ParserPluginWithOptions = export type ParserPluginWithOptions =

View File

@@ -11,7 +11,9 @@ var _builder = _interopRequireDefault(require("./builder"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const smart = (0, _builder.default)(formatters.smart); const smart = (0, _builder.default)(formatters.smart);
exports.smart = smart; exports.smart = smart;

View File

@@ -17,7 +17,7 @@ function merge(a, b) {
syntacticPlaceholders = a.syntacticPlaceholders syntacticPlaceholders = a.syntacticPlaceholders
} = b; } = b;
return { return {
parser: Object.assign({}, a.parser, b.parser), parser: Object.assign({}, a.parser, {}, b.parser),
placeholderWhitelist, placeholderWhitelist,
placeholderPattern, placeholderPattern,
preserveComments, preserveComments,

View File

@@ -5,37 +5,15 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = parseAndBuildMetadata; exports.default = parseAndBuildMetadata;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { var _parser = require("@babel/parser");
return data;
};
return data; var _codeFrame = require("@babel/code-frame");
}
function _parser() { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
const data = require("@babel/parser");
_parser = function () { function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
return data;
};
return data;
}
function _codeFrame() {
const data = require("@babel/code-frame");
_codeFrame = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
const PATTERN = /^[_$A-Z0-9]+$/; const PATTERN = /^[_$A-Z0-9]+$/;
@@ -47,7 +25,7 @@ function parseAndBuildMetadata(formatter, code, opts) {
preserveComments, preserveComments,
syntacticPlaceholders syntacticPlaceholders
} = opts; } = opts;
t().removePropertiesDeep(ast, { t.removePropertiesDeep(ast, {
preserveComments preserveComments
}); });
formatter.validate(ast); formatter.validate(ast);
@@ -62,7 +40,7 @@ function parseAndBuildMetadata(formatter, code, opts) {
const isLegacyRef = { const isLegacyRef = {
value: undefined value: undefined
}; };
t().traverse(ast, placeholderVisitorHandler, { t.traverse(ast, placeholderVisitorHandler, {
syntactic, syntactic,
legacy, legacy,
isLegacyRef, isLegacyRef,
@@ -78,7 +56,7 @@ function parseAndBuildMetadata(formatter, code, opts) {
function placeholderVisitorHandler(node, ancestors, state) { function placeholderVisitorHandler(node, ancestors, state) {
let name; let name;
if (t().isPlaceholder(node)) { if (t.isPlaceholder(node)) {
if (state.syntacticPlaceholders === false) { if (state.syntacticPlaceholders === false) {
throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false."); throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false.");
} else { } else {
@@ -87,10 +65,10 @@ function placeholderVisitorHandler(node, ancestors, state) {
} }
} else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) { } else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) {
return; return;
} else if (t().isIdentifier(node) || t().isJSXIdentifier(node)) { } else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) {
name = node.name; name = node.name;
state.isLegacyRef.value = true; state.isLegacyRef.value = true;
} else if (t().isStringLiteral(node)) { } else if (t.isStringLiteral(node)) {
name = node.value; name = node.value;
state.isLegacyRef.value = true; state.isLegacyRef.value = true;
} else { } else {
@@ -112,16 +90,16 @@ function placeholderVisitorHandler(node, ancestors, state) {
} = ancestors[ancestors.length - 1]; } = ancestors[ancestors.length - 1];
let type; let type;
if (t().isStringLiteral(node) || t().isPlaceholder(node, { if (t.isStringLiteral(node) || t.isPlaceholder(node, {
expectedNode: "StringLiteral" expectedNode: "StringLiteral"
})) { })) {
type = "string"; type = "string";
} else if (t().isNewExpression(parent) && key === "arguments" || t().isCallExpression(parent) && key === "arguments" || t().isFunction(parent) && key === "params") { } else if (t.isNewExpression(parent) && key === "arguments" || t.isCallExpression(parent) && key === "arguments" || t.isFunction(parent) && key === "params") {
type = "param"; type = "param";
} else if (t().isExpressionStatement(parent) && !t().isPlaceholder(node)) { } else if (t.isExpressionStatement(parent) && !t.isPlaceholder(node)) {
type = "statement"; type = "statement";
ancestors = ancestors.slice(0, -1); ancestors = ancestors.slice(0, -1);
} else if (t().isStatement(node) && t().isPlaceholder(node)) { } else if (t.isStatement(node) && t.isPlaceholder(node)) {
type = "statement"; type = "statement";
} else { } else {
type = "other"; type = "other";
@@ -177,12 +155,12 @@ function parseWithCodeFrame(code, parserOpts) {
}); });
try { try {
return (0, _parser().parse)(code, parserOpts); return (0, _parser.parse)(code, parserOpts);
} catch (err) { } catch (err) {
const loc = err.loc; const loc = err.loc;
if (loc) { if (loc) {
err.message += "\n" + (0, _codeFrame().codeFrameColumns)(code, { err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, {
start: loc start: loc
}); });
err.code = "BABEL_TEMPLATE_PARSE_ERROR"; err.code = "BABEL_TEMPLATE_PARSE_ERROR";

View File

@@ -5,20 +5,14 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = populatePlaceholders; exports.default = populatePlaceholders;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function populatePlaceholders(metadata, replacements) { function populatePlaceholders(metadata, replacements) {
const ast = t().cloneNode(metadata.ast); const ast = t.cloneNode(metadata.ast);
if (replacements) { if (replacements) {
metadata.placeholders.forEach(placeholder => { metadata.placeholders.forEach(placeholder => {
@@ -51,9 +45,9 @@ function populatePlaceholders(metadata, replacements) {
function applyReplacement(placeholder, ast, replacement) { function applyReplacement(placeholder, ast, replacement) {
if (placeholder.isDuplicate) { if (placeholder.isDuplicate) {
if (Array.isArray(replacement)) { if (Array.isArray(replacement)) {
replacement = replacement.map(node => t().cloneNode(node)); replacement = replacement.map(node => t.cloneNode(node));
} else if (typeof replacement === "object") { } else if (typeof replacement === "object") {
replacement = t().cloneNode(replacement); replacement = t.cloneNode(replacement);
} }
} }
@@ -65,43 +59,43 @@ function applyReplacement(placeholder, ast, replacement) {
if (placeholder.type === "string") { if (placeholder.type === "string") {
if (typeof replacement === "string") { if (typeof replacement === "string") {
replacement = t().stringLiteral(replacement); replacement = t.stringLiteral(replacement);
} }
if (!replacement || !t().isStringLiteral(replacement)) { if (!replacement || !t.isStringLiteral(replacement)) {
throw new Error("Expected string substitution"); throw new Error("Expected string substitution");
} }
} else if (placeholder.type === "statement") { } else if (placeholder.type === "statement") {
if (index === undefined) { if (index === undefined) {
if (!replacement) { if (!replacement) {
replacement = t().emptyStatement(); replacement = t.emptyStatement();
} else if (Array.isArray(replacement)) { } else if (Array.isArray(replacement)) {
replacement = t().blockStatement(replacement); replacement = t.blockStatement(replacement);
} else if (typeof replacement === "string") { } else if (typeof replacement === "string") {
replacement = t().expressionStatement(t().identifier(replacement)); replacement = t.expressionStatement(t.identifier(replacement));
} else if (!t().isStatement(replacement)) { } else if (!t.isStatement(replacement)) {
replacement = t().expressionStatement(replacement); replacement = t.expressionStatement(replacement);
} }
} else { } else {
if (replacement && !Array.isArray(replacement)) { if (replacement && !Array.isArray(replacement)) {
if (typeof replacement === "string") { if (typeof replacement === "string") {
replacement = t().identifier(replacement); replacement = t.identifier(replacement);
} }
if (!t().isStatement(replacement)) { if (!t.isStatement(replacement)) {
replacement = t().expressionStatement(replacement); replacement = t.expressionStatement(replacement);
} }
} }
} }
} else if (placeholder.type === "param") { } else if (placeholder.type === "param") {
if (typeof replacement === "string") { if (typeof replacement === "string") {
replacement = t().identifier(replacement); replacement = t.identifier(replacement);
} }
if (index === undefined) throw new Error("Assertion failure."); if (index === undefined) throw new Error("Assertion failure.");
} else { } else {
if (typeof replacement === "string") { if (typeof replacement === "string") {
replacement = t().identifier(replacement); replacement = t.identifier(replacement);
} }
if (Array.isArray(replacement)) { if (Array.isArray(replacement)) {
@@ -110,7 +104,7 @@ function applyReplacement(placeholder, ast, replacement) {
} }
if (index === undefined) { if (index === undefined) {
t().validate(parent, key, replacement); t.validate(parent, key, replacement);
parent[key] = replacement; parent[key] = replacement;
} else { } else {
const items = parent[key].slice(); const items = parent[key].slice();
@@ -127,7 +121,7 @@ function applyReplacement(placeholder, ast, replacement) {
items[index] = replacement; items[index] = replacement;
} }
t().validate(parent, key, items); t.validate(parent, key, items);
parent[key] = items; parent[key] = items;
} }
} }

View File

@@ -1,27 +1,20 @@
{ {
"_args": [ "_from": "@babel/template@^7.7.0",
[ "_id": "@babel/template@7.7.0",
"@babel/template@7.4.4",
"/Users/imranismail/Projects/setup-kustomize"
]
],
"_development": true,
"_from": "@babel/template@7.4.4",
"_id": "@babel/template@7.4.4",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", "_integrity": "sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ==",
"_location": "/@babel/template", "_location": "/@babel/template",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "@babel/template@7.4.4", "raw": "@babel/template@^7.7.0",
"name": "@babel/template", "name": "@babel/template",
"escapedName": "@babel%2ftemplate", "escapedName": "@babel%2ftemplate",
"scope": "@babel", "scope": "@babel",
"rawSpec": "7.4.4", "rawSpec": "^7.7.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "7.4.4" "fetchSpec": "^7.7.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/@babel/core", "/@babel/core",
@@ -29,20 +22,23 @@
"/@babel/helpers", "/@babel/helpers",
"/istanbul-lib-instrument" "/istanbul-lib-instrument"
], ],
"_resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", "_resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.0.tgz",
"_spec": "7.4.4", "_shasum": "4fadc1b8e734d97f56de39c77de76f2562e597d0",
"_where": "/Users/imranismail/Projects/setup-kustomize", "_spec": "@babel/template@^7.7.0",
"_where": "/Users/imranismail/Projects/setup-kustomize/node_modules/@babel/core",
"author": { "author": {
"name": "Sebastian McKenzie", "name": "Sebastian McKenzie",
"email": "sebmck@gmail.com" "email": "sebmck@gmail.com"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"@babel/parser": "^7.4.4", "@babel/parser": "^7.7.0",
"@babel/types": "^7.4.4" "@babel/types": "^7.7.0"
}, },
"deprecated": false,
"description": "Generate an AST from a string template.", "description": "Generate an AST from a string template.",
"gitHead": "2c88694388831b1e5b88e4bbed6781eb2be1edba", "gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",
"license": "MIT", "license": "MIT",
"main": "lib/index.js", "main": "lib/index.js",
@@ -54,5 +50,5 @@
"type": "git", "type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-template" "url": "https://github.com/babel/babel/tree/master/packages/babel-template"
}, },
"version": "7.4.4" "version": "7.7.0"
} }

View File

@@ -7,17 +7,11 @@ exports.default = void 0;
var _path = _interopRequireDefault(require("./path")); var _path = _interopRequireDefault(require("./path"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -36,7 +30,7 @@ class TraversalContext {
const opts = this.opts; const opts = this.opts;
if (opts.enter || opts.exit) return true; if (opts.enter || opts.exit) return true;
if (opts[node.type]) return true; if (opts[node.type]) return true;
const keys = t().VISITOR_KEYS[node.type]; const keys = t.VISITOR_KEYS[node.type];
if (!keys || !keys.length) return false; if (!keys || !keys.length) return false;
for (const key of keys) { for (const key of keys) {

View File

@@ -30,25 +30,9 @@ var visitors = _interopRequireWildcard(require("./visitors"));
exports.visitors = visitors; exports.visitors = visitors;
function _includes() { var _includes = _interopRequireDefault(require("lodash/includes"));
const data = _interopRequireDefault(require("lodash/includes"));
_includes = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var cache = _interopRequireWildcard(require("./cache")); var cache = _interopRequireWildcard(require("./cache"));
@@ -58,7 +42,9 @@ var _scope = _interopRequireDefault(require("./scope"));
var _hub = _interopRequireDefault(require("./hub")); var _hub = _interopRequireDefault(require("./hub"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -72,6 +58,10 @@ function traverse(parent, opts, scope, state, parentPath) {
} }
} }
if (!t.VISITOR_KEYS[parent.type]) {
return;
}
visitors.explode(opts); visitors.explode(opts);
traverse.node(parent, opts, scope, state, parentPath); traverse.node(parent, opts, scope, state, parentPath);
} }
@@ -81,11 +71,11 @@ traverse.verify = visitors.verify;
traverse.explode = visitors.explode; traverse.explode = visitors.explode;
traverse.cheap = function (node, enter) { traverse.cheap = function (node, enter) {
return t().traverseFast(node, enter); return t.traverseFast(node, enter);
}; };
traverse.node = function (node, opts, scope, state, parentPath, skipKeys) { traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
const keys = t().VISITOR_KEYS[node.type]; const keys = t.VISITOR_KEYS[node.type];
if (!keys) return; if (!keys) return;
const context = new _context.default(scope, opts, state, parentPath); const context = new _context.default(scope, opts, state, parentPath);
@@ -96,12 +86,12 @@ traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
}; };
traverse.clearNode = function (node, opts) { traverse.clearNode = function (node, opts) {
t().removeProperties(node, opts); t.removeProperties(node, opts);
cache.path.delete(node); cache.path.delete(node);
}; };
traverse.removeProperties = function (tree, opts) { traverse.removeProperties = function (tree, opts) {
t().traverseFast(tree, traverse.clearNode, opts); t.traverseFast(tree, traverse.clearNode, opts);
return tree; return tree;
}; };
@@ -113,7 +103,7 @@ function hasBlacklistedType(path, state) {
} }
traverse.hasType = function (tree, type, blacklistTypes) { traverse.hasType = function (tree, type, blacklistTypes) {
if ((0, _includes().default)(blacklistTypes, tree.type)) return false; if ((0, _includes.default)(blacklistTypes, tree.type)) return false;
if (tree.type === type) return true; if (tree.type === type) return true;
const state = { const state = {
has: false, has: false,

View File

@@ -14,21 +14,15 @@ exports.isAncestor = isAncestor;
exports.isDescendant = isDescendant; exports.isDescendant = isDescendant;
exports.inType = inType; exports.inType = inType;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _index = _interopRequireDefault(require("./index")); var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function findParent(callback) { function findParent(callback) {
let path = this; let path = this;
@@ -75,7 +69,7 @@ function getStatementParent() {
function getEarliestCommonAncestorFrom(paths) { function getEarliestCommonAncestorFrom(paths) {
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) { return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
let earliest; let earliest;
const keys = t().VISITOR_KEYS[deepest.type]; const keys = t.VISITOR_KEYS[deepest.type];
for (const ancestry of ancestries) { for (const ancestry of ancestries) {
const path = ancestry[i + 1]; const path = ancestry[i + 1];

View File

@@ -7,17 +7,11 @@ exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
exports.addComment = addComment; exports.addComment = addComment;
exports.addComments = addComments; exports.addComments = addComments;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function shareCommentsWithSiblings() { function shareCommentsWithSiblings() {
if (typeof this.key === "string") return; if (typeof this.key === "string") return;
@@ -39,9 +33,9 @@ function shareCommentsWithSiblings() {
} }
function addComment(type, content, line) { function addComment(type, content, line) {
t().addComment(this.node, type, content, line); t.addComment(this.node, type, content, line);
} }
function addComments(type, comments) { function addComments(type, comments) {
t().addComments(this.node, type, comments); t.addComments(this.node, type, comments);
} }

View File

@@ -26,6 +26,8 @@ exports._getQueueContexts = _getQueueContexts;
var _index = _interopRequireDefault(require("../index")); var _index = _interopRequireDefault(require("../index"));
var _index2 = require("./index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function call(key) { function call(key) {
@@ -61,7 +63,7 @@ function _call(fns) {
} }
if (this.node !== node) return true; if (this.node !== node) return true;
if (this.shouldStop || this.shouldSkip || this.removed) return true; if (this._traverseFlags > 0) return true;
} }
return false; return false;
@@ -85,7 +87,7 @@ function visit() {
return false; return false;
} }
if (this.call("enter") || this.shouldSkip) { if (this.shouldSkip || this.call("enter") || this.shouldSkip) {
this.debug("Skip..."); this.debug("Skip...");
return this.shouldStop; return this.shouldStop;
} }
@@ -103,12 +105,15 @@ function skip() {
} }
function skipKey(key) { function skipKey(key) {
if (this.skipKeys == null) {
this.skipKeys = {};
}
this.skipKeys[key] = true; this.skipKeys[key] = true;
} }
function stop() { function stop() {
this.shouldStop = true; this._traverseFlags |= _index2.SHOULD_SKIP | _index2.SHOULD_STOP;
this.shouldSkip = true;
} }
function setScope() { function setScope() {
@@ -127,10 +132,11 @@ function setScope() {
} }
function setContext(context) { function setContext(context) {
this.shouldSkip = false; if (this.skipKeys != null) {
this.shouldStop = false; this.skipKeys = {};
this.removed = false; }
this.skipKeys = {};
this._traverseFlags = 0;
if (context) { if (context) {
this.context = context; this.context = context;
@@ -208,9 +214,7 @@ function pushContext(context) {
} }
function setup(parentPath, container, listKey, key) { function setup(parentPath, container, listKey, key) {
this.inList = !!listKey;
this.listKey = listKey; this.listKey = listKey;
this.parentKey = listKey || key;
this.container = container; this.container = container;
this.parentPath = parentPath || this.parentPath; this.parentPath = parentPath || this.parentPath;
this.setKey(key); this.setKey(key);

View File

@@ -9,29 +9,15 @@ exports.arrowFunctionToShadowed = arrowFunctionToShadowed;
exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment; exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
exports.arrowFunctionToExpression = arrowFunctionToExpression; exports.arrowFunctionToExpression = arrowFunctionToExpression;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name"));
return data;
};
return data;
}
function _helperFunctionName() {
const data = _interopRequireDefault(require("@babel/helper-function-name"));
_helperFunctionName = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function toComputedKey() { function toComputedKey() {
const node = this.node; const node = this.node;
@@ -46,7 +32,7 @@ function toComputedKey() {
} }
if (!node.computed) { if (!node.computed) {
if (t().isIdentifier(key)) key = t().stringLiteral(key.name); if (t.isIdentifier(key)) key = t.stringLiteral(key.name);
} }
return key; return key;
@@ -82,14 +68,14 @@ function ensureBlock() {
if (this.isFunction()) { if (this.isFunction()) {
key = "argument"; key = "argument";
statements.push(t().returnStatement(body.node)); statements.push(t.returnStatement(body.node));
} else { } else {
key = "expression"; key = "expression";
statements.push(t().expressionStatement(body.node)); statements.push(t.expressionStatement(body.node));
} }
} }
this.node.body = t().blockStatement(statements); this.node.body = t.blockStatement(statements);
const parentPath = this.get(stringPath); const parentPath = this.get(stringPath);
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key); body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
return this.node; return this.node;
@@ -126,12 +112,12 @@ function arrowFunctionToExpression({
if (checkBinding) { if (checkBinding) {
this.parentPath.scope.push({ this.parentPath.scope.push({
id: checkBinding, id: checkBinding,
init: t().objectExpression([]) init: t.objectExpression([])
}); });
} }
this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)]))); this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)])));
this.replaceWith(t().callExpression(t().memberExpression((0, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()])); this.replaceWith(t.callExpression(t.memberExpression((0, _helperFunctionName.default)(this, true) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
} }
} }
@@ -179,40 +165,25 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
}); });
const superBinding = getSuperBinding(thisEnvFn); const superBinding = getSuperBinding(thisEnvFn);
allSuperCalls.forEach(superCall => { allSuperCalls.forEach(superCall => {
const callee = t().identifier(superBinding); const callee = t.identifier(superBinding);
callee.loc = superCall.node.callee.loc; callee.loc = superCall.node.callee.loc;
superCall.get("callee").replaceWith(callee); superCall.get("callee").replaceWith(callee);
}); });
} }
let thisBinding;
if (thisPaths.length > 0 || specCompliant) {
thisBinding = getThisBinding(thisEnvFn, inConstructor);
if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
thisPaths.forEach(thisChild => {
const thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding);
thisRef.loc = thisChild.node.loc;
thisChild.replaceWith(thisRef);
});
if (specCompliant) thisBinding = null;
}
}
if (argumentsPaths.length > 0) { if (argumentsPaths.length > 0) {
const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t().identifier("arguments")); const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t.identifier("arguments"));
argumentsPaths.forEach(argumentsChild => { argumentsPaths.forEach(argumentsChild => {
const argsRef = t().identifier(argumentsBinding); const argsRef = t.identifier(argumentsBinding);
argsRef.loc = argumentsChild.node.loc; argsRef.loc = argumentsChild.node.loc;
argumentsChild.replaceWith(argsRef); argumentsChild.replaceWith(argsRef);
}); });
} }
if (newTargetPaths.length > 0) { if (newTargetPaths.length > 0) {
const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t().metaProperty(t().identifier("new"), t().identifier("target"))); const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t.metaProperty(t.identifier("new"), t.identifier("target")));
newTargetPaths.forEach(targetChild => { newTargetPaths.forEach(targetChild => {
const targetRef = t().identifier(newTargetBinding); const targetRef = t.identifier(newTargetBinding);
targetRef.loc = targetChild.node.loc; targetRef.loc = targetChild.node.loc;
targetChild.replaceWith(targetRef); targetChild.replaceWith(targetRef);
}); });
@@ -226,41 +197,53 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []); const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
flatSuperProps.forEach(superProp => { flatSuperProps.forEach(superProp => {
const key = superProp.node.computed ? "" : superProp.get("property").node.name; const key = superProp.node.computed ? "" : superProp.get("property").node.name;
const isAssignment = superProp.parentPath.isAssignmentExpression({
if (superProp.parentPath.isCallExpression({ left: superProp.node
});
const isCall = superProp.parentPath.isCallExpression({
callee: superProp.node callee: superProp.node
})) { });
const superBinding = getSuperPropCallBinding(thisEnvFn, key); const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
const args = [];
if (superProp.node.computed) { if (superProp.node.computed) {
const prop = superProp.get("property").node; args.push(superProp.get("property").node);
superProp.replaceWith(t().identifier(superBinding)); }
superProp.parentPath.node.arguments.unshift(prop);
} else { if (isAssignment) {
superProp.replaceWith(t().identifier(superBinding)); const value = superProp.parentPath.node.right;
} args.push(value);
}
const call = t.callExpression(t.identifier(superBinding), args);
if (isCall) {
superProp.parentPath.unshiftContainer("arguments", t.thisExpression());
superProp.replaceWith(t.memberExpression(call, t.identifier("call")));
thisPaths.push(superProp.parentPath.get("arguments.0"));
} else if (isAssignment) {
superProp.parentPath.replaceWith(call);
} else { } else {
const isAssignment = superProp.parentPath.isAssignmentExpression({ superProp.replaceWith(call);
left: superProp.node
});
const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
const args = [];
if (superProp.node.computed) {
args.push(superProp.get("property").node);
}
if (isAssignment) {
const value = superProp.parentPath.node.right;
args.push(value);
superProp.parentPath.replaceWith(t().callExpression(t().identifier(superBinding), args));
} else {
superProp.replaceWith(t().callExpression(t().identifier(superBinding), args));
}
} }
}); });
} }
let thisBinding;
if (thisPaths.length > 0 || specCompliant) {
thisBinding = getThisBinding(thisEnvFn, inConstructor);
if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
thisPaths.forEach(thisChild => {
const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
thisRef.loc = thisChild.node.loc;
thisChild.replaceWith(thisRef);
});
if (specCompliant) thisBinding = null;
}
}
return thisBinding; return thisBinding;
} }
@@ -273,11 +256,11 @@ function standardizeSuperProperty(superProp) {
if (superProp.node.computed) { if (superProp.node.computed) {
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true)); assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, t.assignmentExpression("=", tmp, superProp.node.property), true));
assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value)); assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(tmp.name), true), value));
} else { } else {
assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, superProp.node.property)); assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, superProp.node.property));
assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(superProp.node.property.name)), value)); assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(superProp.node.property.name)), value));
} }
return [assignmentPath.get("left"), assignmentPath.get("right").get("left")]; return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
@@ -285,13 +268,13 @@ function standardizeSuperProperty(superProp) {
const updateExpr = superProp.parentPath; const updateExpr = superProp.parentPath;
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null; const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
const parts = [t().assignmentExpression("=", tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(tmp.name), t().numericLiteral(1)))]; const parts = [t.assignmentExpression("=", tmp, t.memberExpression(superProp.node.object, computedKey ? t.assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t.assignmentExpression("=", t.memberExpression(superProp.node.object, computedKey ? t.identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t.binaryExpression("+", t.identifier(tmp.name), t.numericLiteral(1)))];
if (!superProp.parentPath.node.prefix) { if (!superProp.parentPath.node.prefix) {
parts.push(t().identifier(tmp.name)); parts.push(t.identifier(tmp.name));
} }
updateExpr.replaceWith(t().sequenceExpression(parts)); updateExpr.replaceWith(t.sequenceExpression(parts));
const left = updateExpr.get("expressions.0.right"); const left = updateExpr.get("expressions.0.right");
const right = updateExpr.get("expressions.1.left"); const right = updateExpr.get("expressions.1.left");
return [left, right]; return [left, right];
@@ -306,7 +289,7 @@ function hasSuperClass(thisEnvFn) {
function getThisBinding(thisEnvFn, inConstructor) { function getThisBinding(thisEnvFn, inConstructor) {
return getBinding(thisEnvFn, "this", thisBinding => { return getBinding(thisEnvFn, "this", thisBinding => {
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression(); if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
const supers = new WeakSet(); const supers = new WeakSet();
thisEnvFn.traverse({ thisEnvFn.traverse({
Function(child) { Function(child) {
@@ -322,7 +305,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
if (!child.get("callee").isSuper()) return; if (!child.get("callee").isSuper()) return;
if (supers.has(child.node)) return; if (supers.has(child.node)) return;
supers.add(child.node); supers.add(child.node);
child.replaceWithMultiple([child.node, t().assignmentExpression("=", t().identifier(thisBinding), t().identifier("this"))]); child.replaceWithMultiple([child.node, t.assignmentExpression("=", t.identifier(thisBinding), t.identifier("this"))]);
} }
}); });
@@ -332,25 +315,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
function getSuperBinding(thisEnvFn) { function getSuperBinding(thisEnvFn) {
return getBinding(thisEnvFn, "supercall", () => { return getBinding(thisEnvFn, "supercall", () => {
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args"); const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))])); return t.arrowFunctionExpression([t.restElement(argsBinding)], t.callExpression(t.super(), [t.spreadElement(t.identifier(argsBinding.name))]));
});
}
function getSuperPropCallBinding(thisEnvFn, propName) {
return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => {
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
const argsList = [t().restElement(argsBinding)];
let fnBody;
if (propName) {
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]);
} else {
const method = thisEnvFn.scope.generateUidIdentifier("prop");
argsList.unshift(method);
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]);
}
return t().arrowFunctionExpression(argsList, fnBody);
}); });
} }
@@ -361,20 +326,20 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
let fnBody; let fnBody;
if (propName) { if (propName) {
fnBody = t().memberExpression(t().super(), t().identifier(propName)); fnBody = t.memberExpression(t.super(), t.identifier(propName));
} else { } else {
const method = thisEnvFn.scope.generateUidIdentifier("prop"); const method = thisEnvFn.scope.generateUidIdentifier("prop");
argsList.unshift(method); argsList.unshift(method);
fnBody = t().memberExpression(t().super(), t().identifier(method.name), true); fnBody = t.memberExpression(t.super(), t.identifier(method.name), true);
} }
if (isAssignment) { if (isAssignment) {
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value"); const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
argsList.push(valueIdent); argsList.push(valueIdent);
fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name)); fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name));
} }
return t().arrowFunctionExpression(argsList, fnBody); return t.arrowFunctionExpression(argsList, fnBody);
}); });
} }

View File

@@ -20,17 +20,11 @@ exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
var _index = _interopRequireDefault(require("./index")); var _index = _interopRequireDefault(require("./index"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -47,6 +41,57 @@ function addCompletionRecords(path, paths) {
return paths; return paths;
} }
function completionRecordForSwitch(cases, paths) {
let isLastCaseWithConsequent = true;
for (let i = cases.length - 1; i >= 0; i--) {
const switchCase = cases[i];
const consequent = switchCase.get("consequent");
let breakStatement;
findBreak: for (const statement of consequent) {
if (statement.isBlockStatement()) {
for (const statementInBlock of statement.get("body")) {
if (statementInBlock.isBreakStatement()) {
breakStatement = statementInBlock;
break findBreak;
}
}
} else if (statement.isBreakStatement()) {
breakStatement = statement;
break;
}
}
if (breakStatement) {
while (breakStatement.key === 0 && breakStatement.parentPath.isBlockStatement()) {
breakStatement = breakStatement.parentPath;
}
const prevSibling = breakStatement.getPrevSibling();
if (breakStatement.key > 0 && (prevSibling.isExpressionStatement() || prevSibling.isBlockStatement())) {
paths = addCompletionRecords(prevSibling, paths);
breakStatement.remove();
} else {
breakStatement.replaceWith(breakStatement.scope.buildUndefinedNode());
paths = addCompletionRecords(breakStatement, paths);
}
} else if (isLastCaseWithConsequent) {
const statementFinder = statement => !statement.isBlockStatement() || statement.get("body").some(statementFinder);
const hasConsequent = consequent.some(statementFinder);
if (hasConsequent) {
paths = addCompletionRecords(consequent[consequent.length - 1], paths);
isLastCaseWithConsequent = false;
}
}
}
return paths;
}
function getCompletionRecords() { function getCompletionRecords() {
let paths = []; let paths = [];
@@ -62,9 +107,10 @@ function getCompletionRecords() {
} else if (this.isTryStatement()) { } else if (this.isTryStatement()) {
paths = addCompletionRecords(this.get("block"), paths); paths = addCompletionRecords(this.get("block"), paths);
paths = addCompletionRecords(this.get("handler"), paths); paths = addCompletionRecords(this.get("handler"), paths);
paths = addCompletionRecords(this.get("finalizer"), paths);
} else if (this.isCatchClause()) { } else if (this.isCatchClause()) {
paths = addCompletionRecords(this.get("body"), paths); paths = addCompletionRecords(this.get("body"), paths);
} else if (this.isSwitchStatement()) {
paths = completionRecordForSwitch(this.get("cases"), paths);
} else { } else {
paths.push(this); paths.push(this);
} }
@@ -170,11 +216,11 @@ function _getPattern(parts, context) {
} }
function getBindingIdentifiers(duplicates) { function getBindingIdentifiers(duplicates) {
return t().getBindingIdentifiers(this.node, duplicates); return t.getBindingIdentifiers(this.node, duplicates);
} }
function getOuterBindingIdentifiers(duplicates) { function getOuterBindingIdentifiers(duplicates) {
return t().getOuterBindingIdentifiers(this.node, duplicates); return t.getOuterBindingIdentifiers(this.node, duplicates);
} }
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) { function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
@@ -186,7 +232,7 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
const id = search.shift(); const id = search.shift();
if (!id) continue; if (!id) continue;
if (!id.node) continue; if (!id.node) continue;
const keys = t().getBindingIdentifiers.keys[id.node.type]; const keys = t.getBindingIdentifiers.keys[id.node.type];
if (id.isIdentifier()) { if (id.isIdentifier()) {
if (duplicates) { if (duplicates) {

View File

@@ -3,45 +3,21 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.default = void 0; exports.default = exports.SHOULD_SKIP = exports.SHOULD_STOP = exports.REMOVED = void 0;
var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types")); var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types"));
function _debug() { var _debug = _interopRequireDefault(require("debug"));
const data = _interopRequireDefault(require("debug"));
_debug = function () {
return data;
};
return data;
}
var _index = _interopRequireDefault(require("../index")); var _index = _interopRequireDefault(require("../index"));
var _scope = _interopRequireDefault(require("../scope")); var _scope = _interopRequireDefault(require("../scope"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _cache = require("../cache"); var _cache = require("../cache");
function _generator() { var _generator = _interopRequireDefault(require("@babel/generator"));
const data = _interopRequireDefault(require("@babel/generator"));
_generator = function () {
return data;
};
return data;
}
var NodePath_ancestry = _interopRequireWildcard(require("./ancestry")); var NodePath_ancestry = _interopRequireWildcard(require("./ancestry"));
@@ -67,19 +43,25 @@ var NodePath_comments = _interopRequireWildcard(require("./comments"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
const debug = (0, _debug().default)("babel"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const debug = (0, _debug.default)("babel");
const REMOVED = 1 << 0;
exports.REMOVED = REMOVED;
const SHOULD_STOP = 1 << 1;
exports.SHOULD_STOP = SHOULD_STOP;
const SHOULD_SKIP = 1 << 2;
exports.SHOULD_SKIP = SHOULD_SKIP;
class NodePath { class NodePath {
constructor(hub, parent) { constructor(hub, parent) {
this.parent = parent; this.parent = parent;
this.hub = hub; this.hub = hub;
this.contexts = []; this.contexts = [];
this.data = Object.create(null); this.data = null;
this.shouldSkip = false; this._traverseFlags = 0;
this.shouldStop = false;
this.removed = false;
this.state = null; this.state = null;
this.opts = null; this.opts = null;
this.skipKeys = null; this.skipKeys = null;
@@ -87,13 +69,10 @@ class NodePath {
this.context = null; this.context = null;
this.container = null; this.container = null;
this.listKey = null; this.listKey = null;
this.inList = false;
this.parentKey = null;
this.key = null; this.key = null;
this.node = null; this.node = null;
this.scope = null; this.scope = null;
this.type = null; this.type = null;
this.typeAnnotation = null;
} }
static get({ static get({
@@ -144,10 +123,18 @@ class NodePath {
} }
setData(key, val) { setData(key, val) {
if (this.data == null) {
this.data = Object.create(null);
}
return this.data[key] = val; return this.data[key] = val;
} }
getData(key, def) { getData(key, def) {
if (this.data == null) {
this.data = Object.create(null);
}
let val = this.data[key]; let val = this.data[key];
if (val === undefined && def !== undefined) val = this.data[key] = def; if (val === undefined && def !== undefined) val = this.data[key] = def;
return val; return val;
@@ -162,7 +149,7 @@ class NodePath {
} }
set(key, node) { set(key, node) {
t().validate(this.node, key, node); t.validate(this.node, key, node);
this.node[key] = node; this.node[key] = node;
} }
@@ -185,7 +172,57 @@ class NodePath {
} }
toString() { toString() {
return (0, _generator().default)(this.node).code; return (0, _generator.default)(this.node).code;
}
get inList() {
return !!this.listKey;
}
set inList(inList) {
if (!inList) {
this.listKey = null;
}
}
get parentKey() {
return this.listKey || this.key;
}
get shouldSkip() {
return !!(this._traverseFlags & SHOULD_SKIP);
}
set shouldSkip(v) {
if (v) {
this._traverseFlags |= SHOULD_SKIP;
} else {
this._traverseFlags &= ~SHOULD_SKIP;
}
}
get shouldStop() {
return !!(this._traverseFlags & SHOULD_STOP);
}
set shouldStop(v) {
if (v) {
this._traverseFlags |= SHOULD_STOP;
} else {
this._traverseFlags &= ~SHOULD_STOP;
}
}
get removed() {
return !!(this._traverseFlags & REMOVED);
}
set removed(v) {
if (v) {
this._traverseFlags |= REMOVED;
} else {
this._traverseFlags &= ~REMOVED;
}
} }
} }
@@ -193,9 +230,9 @@ class NodePath {
exports.default = NodePath; exports.default = NodePath;
Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments); Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments);
for (const type of t().TYPES) { for (const type of t.TYPES) {
const typeKey = `is${type}`; const typeKey = `is${type}`;
const fn = t()[typeKey]; const fn = t[typeKey];
NodePath.prototype[typeKey] = function (opts) { NodePath.prototype[typeKey] = function (opts) {
return fn(this.node, opts); return fn(this.node, opts);
@@ -210,7 +247,7 @@ for (const type of t().TYPES) {
for (const type of Object.keys(virtualTypes)) { for (const type of Object.keys(virtualTypes)) {
if (type[0] === "_") continue; if (type[0] === "_") continue;
if (t().TYPES.indexOf(type) < 0) t().TYPES.push(type); if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type);
const virtualType = virtualTypes[type]; const virtualType = virtualTypes[type];
NodePath.prototype[`is${type}`] = function (opts) { NodePath.prototype[`is${type}`] = function (opts) {

View File

@@ -12,22 +12,16 @@ exports.isGenericType = isGenericType;
var inferers = _interopRequireWildcard(require("./inferers")); var inferers = _interopRequireWildcard(require("./inferers"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function getTypeAnnotation() { function getTypeAnnotation() {
if (this.typeAnnotation) return this.typeAnnotation; if (this.typeAnnotation) return this.typeAnnotation;
let type = this._getTypeAnnotation() || t().anyTypeAnnotation(); let type = this._getTypeAnnotation() || t.anyTypeAnnotation();
if (t().isTypeAnnotation(type)) type = type.typeAnnotation; if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
return this.typeAnnotation = type; return this.typeAnnotation = type;
} }
@@ -40,14 +34,14 @@ function _getTypeAnnotation() {
const declarParent = declar.parentPath; const declarParent = declar.parentPath;
if (declar.key === "left" && declarParent.isForInStatement()) { if (declar.key === "left" && declarParent.isForInStatement()) {
return t().stringTypeAnnotation(); return t.stringTypeAnnotation();
} }
if (declar.key === "left" && declarParent.isForOfStatement()) { if (declar.key === "left" && declarParent.isForOfStatement()) {
return t().anyTypeAnnotation(); return t.anyTypeAnnotation();
} }
return t().voidTypeAnnotation(); return t.voidTypeAnnotation();
} else { } else {
return; return;
} }
@@ -76,19 +70,19 @@ function isBaseType(baseName, soft) {
function _isBaseType(baseName, type, soft) { function _isBaseType(baseName, type, soft) {
if (baseName === "string") { if (baseName === "string") {
return t().isStringTypeAnnotation(type); return t.isStringTypeAnnotation(type);
} else if (baseName === "number") { } else if (baseName === "number") {
return t().isNumberTypeAnnotation(type); return t.isNumberTypeAnnotation(type);
} else if (baseName === "boolean") { } else if (baseName === "boolean") {
return t().isBooleanTypeAnnotation(type); return t.isBooleanTypeAnnotation(type);
} else if (baseName === "any") { } else if (baseName === "any") {
return t().isAnyTypeAnnotation(type); return t.isAnyTypeAnnotation(type);
} else if (baseName === "mixed") { } else if (baseName === "mixed") {
return t().isMixedTypeAnnotation(type); return t.isMixedTypeAnnotation(type);
} else if (baseName === "empty") { } else if (baseName === "empty") {
return t().isEmptyTypeAnnotation(type); return t.isEmptyTypeAnnotation(type);
} else if (baseName === "void") { } else if (baseName === "void") {
return t().isVoidTypeAnnotation(type); return t.isVoidTypeAnnotation(type);
} else { } else {
if (soft) { if (soft) {
return false; return false;
@@ -100,11 +94,11 @@ function _isBaseType(baseName, type, soft) {
function couldBeBaseType(name) { function couldBeBaseType(name) {
const type = this.getTypeAnnotation(); const type = this.getTypeAnnotation();
if (t().isAnyTypeAnnotation(type)) return true; if (t.isAnyTypeAnnotation(type)) return true;
if (t().isUnionTypeAnnotation(type)) { if (t.isUnionTypeAnnotation(type)) {
for (const type2 of type.types) { for (const type2 of type.types) {
if (t().isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) { if (t.isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
return true; return true;
} }
} }
@@ -119,14 +113,14 @@ function baseTypeStrictlyMatches(right) {
const left = this.getTypeAnnotation(); const left = this.getTypeAnnotation();
right = right.getTypeAnnotation(); right = right.getTypeAnnotation();
if (!t().isAnyTypeAnnotation(left) && t().isFlowBaseAnnotation(left)) { if (!t.isAnyTypeAnnotation(left) && t.isFlowBaseAnnotation(left)) {
return right.type === left.type; return right.type === left.type;
} }
} }
function isGenericType(genericName) { function isGenericType(genericName) {
const type = this.getTypeAnnotation(); const type = this.getTypeAnnotation();
return t().isGenericTypeAnnotation(type) && t().isIdentifier(type.id, { return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, {
name: genericName name: genericName
}); });
} }

View File

@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = _default; exports.default = _default;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _default(node) { function _default(node) {
if (!this.isReferenced()) return; if (!this.isReferenced()) return;
@@ -30,9 +24,9 @@ function _default(node) {
} }
if (node.name === "undefined") { if (node.name === "undefined") {
return t().voidTypeAnnotation(); return t.voidTypeAnnotation();
} else if (node.name === "NaN" || node.name === "Infinity") { } else if (node.name === "NaN" || node.name === "Infinity") {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} else if (node.name === "arguments") {} } else if (node.name === "arguments") {}
} }
@@ -57,7 +51,7 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) {
} }
if (types.length) { if (types.length) {
return t().createUnionTypeAnnotation(types); return t.createUnionTypeAnnotation(types);
} }
} }
@@ -69,7 +63,7 @@ function getConstantViolationsBefore(binding, path, functions) {
const status = violation._guessExecutionStatusRelativeTo(path); const status = violation._guessExecutionStatusRelativeTo(path);
if (functions && status === "function") functions.push(violation); if (functions && status === "unknown") functions.push(violation);
return status === "before"; return status === "before";
}); });
} }
@@ -95,8 +89,8 @@ function inferAnnotationFromBinaryExpression(name, path) {
return target.getTypeAnnotation(); return target.getTypeAnnotation();
} }
if (t().BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} }
return; return;
@@ -126,7 +120,7 @@ function inferAnnotationFromBinaryExpression(name, path) {
if (!typePath.isLiteral()) return; if (!typePath.isLiteral()) return;
const typeValue = typePath.node.value; const typeValue = typePath.node.value;
if (typeof typeValue !== "string") return; if (typeof typeValue !== "string") return;
return t().createTypeAnnotationBasedOnTypeof(typeValue); return t.createTypeAnnotationBasedOnTypeof(typeValue);
} }
function getParentConditionalPath(binding, path, name) { function getParentConditionalPath(binding, path, name) {
@@ -172,7 +166,7 @@ function getConditionalAnnotation(binding, path, name) {
if (types.length) { if (types.length) {
return { return {
typeAnnotation: t().createUnionTypeAnnotation(types), typeAnnotation: t.createUnionTypeAnnotation(types),
ifStatement ifStatement
}; };
} }

View File

@@ -33,21 +33,15 @@ Object.defineProperty(exports, "Identifier", {
} }
}); });
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _infererReference = _interopRequireDefault(require("./inferer-reference")); var _infererReference = _interopRequireDefault(require("./inferer-reference"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function VariableDeclarator() { function VariableDeclarator() {
const id = this.get("id"); const id = this.get("id");
@@ -74,55 +68,55 @@ TypeCastExpression.validParent = true;
function NewExpression(node) { function NewExpression(node) {
if (this.get("callee").isIdentifier()) { if (this.get("callee").isIdentifier()) {
return t().genericTypeAnnotation(node.callee); return t.genericTypeAnnotation(node.callee);
} }
} }
function TemplateLiteral() { function TemplateLiteral() {
return t().stringTypeAnnotation(); return t.stringTypeAnnotation();
} }
function UnaryExpression(node) { function UnaryExpression(node) {
const operator = node.operator; const operator = node.operator;
if (operator === "void") { if (operator === "void") {
return t().voidTypeAnnotation(); return t.voidTypeAnnotation();
} else if (t().NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) { } else if (t.NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} else if (t().STRING_UNARY_OPERATORS.indexOf(operator) >= 0) { } else if (t.STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t().stringTypeAnnotation(); return t.stringTypeAnnotation();
} else if (t().BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) { } else if (t.BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t().booleanTypeAnnotation(); return t.booleanTypeAnnotation();
} }
} }
function BinaryExpression(node) { function BinaryExpression(node) {
const operator = node.operator; const operator = node.operator;
if (t().NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { if (t.NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} else if (t().BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) { } else if (t.BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t().booleanTypeAnnotation(); return t.booleanTypeAnnotation();
} else if (operator === "+") { } else if (operator === "+") {
const right = this.get("right"); const right = this.get("right");
const left = this.get("left"); const left = this.get("left");
if (left.isBaseType("number") && right.isBaseType("number")) { if (left.isBaseType("number") && right.isBaseType("number")) {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} else if (left.isBaseType("string") || right.isBaseType("string")) { } else if (left.isBaseType("string") || right.isBaseType("string")) {
return t().stringTypeAnnotation(); return t.stringTypeAnnotation();
} }
return t().unionTypeAnnotation([t().stringTypeAnnotation(), t().numberTypeAnnotation()]); return t.unionTypeAnnotation([t.stringTypeAnnotation(), t.numberTypeAnnotation()]);
} }
} }
function LogicalExpression() { function LogicalExpression() {
return t().createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]); return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
} }
function ConditionalExpression() { function ConditionalExpression() {
return t().createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]); return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
} }
function SequenceExpression() { function SequenceExpression() {
@@ -141,36 +135,36 @@ function UpdateExpression(node) {
const operator = node.operator; const operator = node.operator;
if (operator === "++" || operator === "--") { if (operator === "++" || operator === "--") {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} }
} }
function StringLiteral() { function StringLiteral() {
return t().stringTypeAnnotation(); return t.stringTypeAnnotation();
} }
function NumericLiteral() { function NumericLiteral() {
return t().numberTypeAnnotation(); return t.numberTypeAnnotation();
} }
function BooleanLiteral() { function BooleanLiteral() {
return t().booleanTypeAnnotation(); return t.booleanTypeAnnotation();
} }
function NullLiteral() { function NullLiteral() {
return t().nullLiteralTypeAnnotation(); return t.nullLiteralTypeAnnotation();
} }
function RegExpLiteral() { function RegExpLiteral() {
return t().genericTypeAnnotation(t().identifier("RegExp")); return t.genericTypeAnnotation(t.identifier("RegExp"));
} }
function ObjectExpression() { function ObjectExpression() {
return t().genericTypeAnnotation(t().identifier("Object")); return t.genericTypeAnnotation(t.identifier("Object"));
} }
function ArrayExpression() { function ArrayExpression() {
return t().genericTypeAnnotation(t().identifier("Array")); return t.genericTypeAnnotation(t.identifier("Array"));
} }
function RestElement() { function RestElement() {
@@ -180,13 +174,13 @@ function RestElement() {
RestElement.validParent = true; RestElement.validParent = true;
function Func() { function Func() {
return t().genericTypeAnnotation(t().identifier("Function")); return t.genericTypeAnnotation(t.identifier("Function"));
} }
const isArrayFrom = t().buildMatchMemberExpression("Array.from"); const isArrayFrom = t.buildMatchMemberExpression("Array.from");
const isObjectKeys = t().buildMatchMemberExpression("Object.keys"); const isObjectKeys = t.buildMatchMemberExpression("Object.keys");
const isObjectValues = t().buildMatchMemberExpression("Object.values"); const isObjectValues = t.buildMatchMemberExpression("Object.values");
const isObjectEntries = t().buildMatchMemberExpression("Object.entries"); const isObjectEntries = t.buildMatchMemberExpression("Object.entries");
function CallExpression() { function CallExpression() {
const { const {
@@ -194,11 +188,11 @@ function CallExpression() {
} = this.node; } = this.node;
if (isObjectKeys(callee)) { if (isObjectKeys(callee)) {
return t().arrayTypeAnnotation(t().stringTypeAnnotation()); return t.arrayTypeAnnotation(t.stringTypeAnnotation());
} else if (isArrayFrom(callee) || isObjectValues(callee)) { } else if (isArrayFrom(callee) || isObjectValues(callee)) {
return t().arrayTypeAnnotation(t().anyTypeAnnotation()); return t.arrayTypeAnnotation(t.anyTypeAnnotation());
} else if (isObjectEntries(callee)) { } else if (isObjectEntries(callee)) {
return t().arrayTypeAnnotation(t().tupleTypeAnnotation([t().stringTypeAnnotation(), t().anyTypeAnnotation()])); return t.arrayTypeAnnotation(t.tupleTypeAnnotation([t.stringTypeAnnotation(), t.anyTypeAnnotation()]));
} }
return resolveCall(this.get("callee")); return resolveCall(this.get("callee"));
@@ -214,9 +208,9 @@ function resolveCall(callee) {
if (callee.isFunction()) { if (callee.isFunction()) {
if (callee.is("async")) { if (callee.is("async")) {
if (callee.is("generator")) { if (callee.is("generator")) {
return t().genericTypeAnnotation(t().identifier("AsyncIterator")); return t.genericTypeAnnotation(t.identifier("AsyncIterator"));
} else { } else {
return t().genericTypeAnnotation(t().identifier("Promise")); return t.genericTypeAnnotation(t.identifier("Promise"));
} }
} else { } else {
if (callee.node.returnType) { if (callee.node.returnType) {

View File

@@ -24,32 +24,18 @@ exports.isConstantExpression = isConstantExpression;
exports.isInStrictMode = isInStrictMode; exports.isInStrictMode = isInStrictMode;
exports.is = void 0; exports.is = void 0;
function _includes() { var _includes = _interopRequireDefault(require("lodash/includes"));
const data = _interopRequireDefault(require("lodash/includes"));
_includes = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
}
function t() { function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function matchesPattern(pattern, allowPartial) { function matchesPattern(pattern, allowPartial) {
return t().matchesPattern(this.node, pattern, allowPartial); return t.matchesPattern(this.node, pattern, allowPartial);
} }
function has(key) { function has(key) {
@@ -78,7 +64,7 @@ function equals(key, value) {
} }
function isNodeType(type) { function isNodeType(type) {
return t().isType(this.type, type); return t.isType(this.type, type);
} }
function canHaveVariableDeclarationOrExpression() { function canHaveVariableDeclarationOrExpression() {
@@ -91,9 +77,9 @@ function canSwapBetweenExpressionAndStatement(replacement) {
} }
if (this.isExpression()) { if (this.isExpression()) {
return t().isBlockStatement(replacement); return t.isBlockStatement(replacement);
} else if (this.isBlockStatement()) { } else if (this.isBlockStatement()) {
return t().isExpression(replacement); return t.isExpression(replacement);
} }
return false; return false;
@@ -121,10 +107,10 @@ function isCompletionRecord(allowInsideFunction) {
} }
function isStatementOrBlock() { function isStatementOrBlock() {
if (this.parentPath.isLabeledStatement() || t().isBlockStatement(this.container)) { if (this.parentPath.isLabeledStatement() || t.isBlockStatement(this.container)) {
return false; return false;
} else { } else {
return (0, _includes().default)(t().STATEMENT_OR_BLOCK_KEYS, this.key); return (0, _includes.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key);
} }
} }
@@ -172,81 +158,147 @@ function willIMaybeExecuteBefore(target) {
return this._guessExecutionStatusRelativeTo(target) !== "after"; return this._guessExecutionStatusRelativeTo(target) !== "after";
} }
function _guessExecutionStatusRelativeTo(target) { function getOuterFunction(path) {
const targetFuncParent = target.scope.getFunctionParent() || target.scope.getProgramParent(); return (path.scope.getFunctionParent() || path.scope.getProgramParent()).path;
const selfFuncParent = this.scope.getFunctionParent() || target.scope.getProgramParent(); }
if (targetFuncParent.node !== selfFuncParent.node) { function isExecutionUncertain(type, key) {
const status = this._guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent); switch (type) {
case "LogicalExpression":
return key === "right";
if (status) { case "ConditionalExpression":
return status; case "IfStatement":
} else { return key === "consequent" || key === "alternate";
target = targetFuncParent.path;
case "WhileStatement":
case "DoWhileStatement":
case "ForInStatement":
case "ForOfStatement":
return key === "body";
case "ForStatement":
return key === "body" || key === "update";
case "SwitchStatement":
return key === "cases";
case "TryStatement":
return key === "handler";
case "AssignmentPattern":
return key === "right";
case "OptionalMemberExpression":
return key === "property";
case "OptionalCallExpression":
return key === "arguments";
default:
return false;
}
}
function isExecutionUncertainInList(paths, maxIndex) {
for (let i = 0; i < maxIndex; i++) {
const path = paths[i];
if (isExecutionUncertain(path.parent.type, path.parentKey)) {
return true;
} }
} }
const targetPaths = target.getAncestry(); return false;
if (targetPaths.indexOf(this) >= 0) return "after"; }
const selfPaths = this.getAncestry();
function _guessExecutionStatusRelativeTo(target) {
const funcParent = {
this: getOuterFunction(this),
target: getOuterFunction(target)
};
if (funcParent.target.node !== funcParent.this.node) {
return this._guessExecutionStatusRelativeToDifferentFunctions(funcParent.target);
}
const paths = {
target: target.getAncestry(),
this: this.getAncestry()
};
if (paths.target.indexOf(this) >= 0) return "after";
if (paths.this.indexOf(target) >= 0) return "before";
let commonPath; let commonPath;
let targetIndex; const commonIndex = {
let selfIndex; target: 0,
this: 0
};
for (selfIndex = 0; selfIndex < selfPaths.length; selfIndex++) { while (!commonPath && commonIndex.this < paths.this.length) {
const selfPath = selfPaths[selfIndex]; const path = paths.this[commonIndex.this];
targetIndex = targetPaths.indexOf(selfPath); commonIndex.target = paths.target.indexOf(path);
if (targetIndex >= 0) { if (commonIndex.target >= 0) {
commonPath = selfPath; commonPath = path;
break; } else {
commonIndex.this++;
} }
} }
if (!commonPath) { if (!commonPath) {
return "before"; throw new Error("Internal Babel error - The two compared nodes" + " don't appear to belong to the same program.");
} }
const targetRelationship = targetPaths[targetIndex - 1]; if (isExecutionUncertainInList(paths.this, commonIndex.this - 1) || isExecutionUncertainInList(paths.target, commonIndex.target - 1)) {
const selfRelationship = selfPaths[selfIndex - 1]; return "unknown";
if (!targetRelationship || !selfRelationship) {
return "before";
} }
if (targetRelationship.listKey && targetRelationship.container === selfRelationship.container) { const divergence = {
return targetRelationship.key > selfRelationship.key ? "before" : "after"; this: paths.this[commonIndex.this - 1],
target: paths.target[commonIndex.target - 1]
};
if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) {
return divergence.target.key > divergence.this.key ? "before" : "after";
} }
const keys = t().VISITOR_KEYS[commonPath.type]; const keys = t.VISITOR_KEYS[commonPath.type];
const targetKeyPosition = keys.indexOf(targetRelationship.key); const keyPosition = {
const selfKeyPosition = keys.indexOf(selfRelationship.key); this: keys.indexOf(divergence.this.parentKey),
return targetKeyPosition > selfKeyPosition ? "before" : "after"; target: keys.indexOf(divergence.target.parentKey)
};
return keyPosition.target > keyPosition.this ? "before" : "after";
} }
function _guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent) { const executionOrderCheckedNodes = new WeakSet();
const targetFuncPath = targetFuncParent.path;
if (!targetFuncPath.isFunctionDeclaration()) return;
const binding = targetFuncPath.scope.getBinding(targetFuncPath.node.id.name);
if (!binding.references) return "before";
const referencePaths = binding.referencePaths;
for (const path of referencePaths) { function _guessExecutionStatusRelativeToDifferentFunctions(target) {
if (path.key !== "callee" || !path.parentPath.isCallExpression()) { if (!target.isFunctionDeclaration() || target.parentPath.isExportDeclaration()) {
return; return "unknown";
}
} }
const binding = target.scope.getBinding(target.node.id.name);
if (!binding.references) return "before";
const referencePaths = binding.referencePaths;
let allStatus; let allStatus;
for (const path of referencePaths) { for (const path of referencePaths) {
const childOfFunction = !!path.find(path => path.node === targetFuncPath.node); const childOfFunction = !!path.find(path => path.node === target.node);
if (childOfFunction) continue; if (childOfFunction) continue;
if (path.key !== "callee" || !path.parentPath.isCallExpression()) {
return "unknown";
}
if (executionOrderCheckedNodes.has(path.node)) continue;
executionOrderCheckedNodes.add(path.node);
const status = this._guessExecutionStatusRelativeTo(path); const status = this._guessExecutionStatusRelativeTo(path);
if (allStatus) { executionOrderCheckedNodes.delete(path.node);
if (allStatus !== status) return;
if (allStatus && allStatus !== status) {
return "unknown";
} else { } else {
allStatus = status; allStatus = status;
} }
@@ -283,7 +335,7 @@ function _resolve(dangerous, resolved) {
return this.get("expression").resolve(dangerous, resolved); return this.get("expression").resolve(dangerous, resolved);
} else if (dangerous && this.isMemberExpression()) { } else if (dangerous && this.isMemberExpression()) {
const targetKey = this.toComputedKey(); const targetKey = this.toComputedKey();
if (!t().isLiteral(targetKey)) return; if (!t.isLiteral(targetKey)) return;
const targetName = targetKey.value; const targetName = targetKey.value;
const target = this.get("object").resolve(dangerous, resolved); const target = this.get("object").resolve(dangerous, resolved);

View File

@@ -5,21 +5,15 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
const referenceVisitor = { const referenceVisitor = {
ReferencedIdentifier(path, state) { ReferencedIdentifier(path, state) {
if (path.isJSXIdentifier() && t().react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) { if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
return; return;
} }
@@ -37,6 +31,15 @@ const referenceVisitor = {
const binding = path.scope.getBinding(path.node.name); const binding = path.scope.getBinding(path.node.name);
if (!binding) return; if (!binding) return;
for (const violation of binding.constantViolations) {
if (violation.scope !== binding.path.scope) {
state.mutableBinding = true;
path.stop();
return;
}
}
if (binding !== state.scope.getBinding(path.node.name)) return; if (binding !== state.scope.getBinding(path.node.name)) return;
state.bindings[path.node.name] = binding; state.bindings[path.node.name] = binding;
} }
@@ -47,6 +50,7 @@ class PathHoister {
constructor(path, scope) { constructor(path, scope) {
this.breakOnScopePaths = []; this.breakOnScopePaths = [];
this.bindings = {}; this.bindings = {};
this.mutableBinding = false;
this.scopes = []; this.scopes = [];
this.scope = scope; this.scope = scope;
this.path = path; this.path = path;
@@ -165,21 +169,22 @@ class PathHoister {
run() { run() {
this.path.traverse(referenceVisitor, this); this.path.traverse(referenceVisitor, this);
if (this.mutableBinding) return;
this.getCompatibleScopes(); this.getCompatibleScopes();
const attachTo = this.getAttachmentPath(); const attachTo = this.getAttachmentPath();
if (!attachTo) return; if (!attachTo) return;
if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return; if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
let uid = attachTo.scope.generateUidIdentifier("ref"); let uid = attachTo.scope.generateUidIdentifier("ref");
const declarator = t().variableDeclarator(uid, this.path.node); const declarator = t.variableDeclarator(uid, this.path.node);
const insertFn = this.attachAfter ? "insertAfter" : "insertBefore"; const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t().variableDeclaration("var", [declarator])]); const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]);
const parent = this.path.parentPath; const parent = this.path.parentPath;
if (parent.isJSXElement() && this.path.container === parent.node.children) { if (parent.isJSXElement() && this.path.container === parent.node.children) {
uid = t().JSXExpressionContainer(uid); uid = t.JSXExpressionContainer(uid);
} }
this.path.replaceWith(t().cloneNode(uid)); this.path.replaceWith(t.cloneNode(uid));
return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init"); return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
} }

View File

@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0; exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0;
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
const ReferencedIdentifier = { const ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"], types: ["Identifier", "JSXIdentifier"],
@@ -26,15 +20,15 @@ const ReferencedIdentifier = {
parent parent
} = path; } = path;
if (!t().isIdentifier(node, opts) && !t().isJSXMemberExpression(parent, opts)) { if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
if (t().isJSXIdentifier(node, opts)) { if (t.isJSXIdentifier(node, opts)) {
if (t().react.isCompatTag(node.name)) return false; if (t.react.isCompatTag(node.name)) return false;
} else { } else {
return false; return false;
} }
} }
return t().isReferenced(node, parent, path.parentPath.parent); return t.isReferenced(node, parent, path.parentPath.parent);
} }
}; };
@@ -46,7 +40,7 @@ const ReferencedMemberExpression = {
node, node,
parent parent
}) { }) {
return t().isMemberExpression(node) && t().isReferenced(node, parent); return t.isMemberExpression(node) && t.isReferenced(node, parent);
} }
}; };
@@ -60,7 +54,7 @@ const BindingIdentifier = {
parent parent
} = path; } = path;
const grandparent = path.parentPath.parent; const grandparent = path.parentPath.parent;
return t().isIdentifier(node) && t().isBinding(node, parent, grandparent); return t.isIdentifier(node) && t.isBinding(node, parent, grandparent);
} }
}; };
@@ -72,12 +66,12 @@ const Statement = {
node, node,
parent parent
}) { }) {
if (t().isStatement(node)) { if (t.isStatement(node)) {
if (t().isVariableDeclaration(node)) { if (t.isVariableDeclaration(node)) {
if (t().isForXStatement(parent, { if (t.isForXStatement(parent, {
left: node left: node
})) return false; })) return false;
if (t().isForStatement(parent, { if (t.isForStatement(parent, {
init: node init: node
})) return false; })) return false;
} }
@@ -97,7 +91,7 @@ const Expression = {
if (path.isIdentifier()) { if (path.isIdentifier()) {
return path.isReferencedIdentifier(); return path.isReferencedIdentifier();
} else { } else {
return t().isExpression(path.node); return t.isExpression(path.node);
} }
} }
@@ -107,21 +101,21 @@ const Scope = {
types: ["Scopable"], types: ["Scopable"],
checkPath(path) { checkPath(path) {
return t().isScope(path.node, path.parent); return t.isScope(path.node, path.parent);
} }
}; };
exports.Scope = Scope; exports.Scope = Scope;
const Referenced = { const Referenced = {
checkPath(path) { checkPath(path) {
return t().isReferenced(path.node, path.parent); return t.isReferenced(path.node, path.parent);
} }
}; };
exports.Referenced = Referenced; exports.Referenced = Referenced;
const BlockScoped = { const BlockScoped = {
checkPath(path) { checkPath(path) {
return t().isBlockScoped(path.node); return t.isBlockScoped(path.node);
} }
}; };
@@ -130,7 +124,7 @@ const Var = {
types: ["VariableDeclaration"], types: ["VariableDeclaration"],
checkPath(path) { checkPath(path) {
return t().isVar(path.node); return t.isVar(path.node);
} }
}; };
@@ -162,13 +156,13 @@ const Flow = {
checkPath({ checkPath({
node node
}) { }) {
if (t().isFlow(node)) { if (t.isFlow(node)) {
return true; return true;
} else if (t().isImportDeclaration(node)) { } else if (t.isImportDeclaration(node)) {
return node.importKind === "type" || node.importKind === "typeof"; return node.importKind === "type" || node.importKind === "typeof";
} else if (t().isExportDeclaration(node)) { } else if (t.isExportDeclaration(node)) {
return node.exportKind === "type"; return node.exportKind === "type";
} else if (t().isImportSpecifier(node)) { } else if (t.isImportSpecifier(node)) {
return node.importKind === "type" || node.importKind === "typeof"; return node.importKind === "type" || node.importKind === "typeof";
} else { } else {
return false; return false;

View File

@@ -20,17 +20,11 @@ var _hoister = _interopRequireDefault(require("./lib/hoister"));
var _index = _interopRequireDefault(require("./index")); var _index = _interopRequireDefault(require("./index"));
function t() { var t = _interopRequireWildcard(require("@babel/types"));
const data = _interopRequireWildcard(require("@babel/types"));
t = function () { function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
return data;
};
return data; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -51,7 +45,7 @@ function insertBefore(nodes) {
return this._containerInsertBefore(nodes); return this._containerInsertBefore(nodes);
} else if (this.isStatementOrBlock()) { } else if (this.isStatementOrBlock()) {
const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null); const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : [])); this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
return this.unshiftContainer("body", nodes); return this.unshiftContainer("body", nodes);
} else { } else {
throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
@@ -105,7 +99,7 @@ function insertAfter(nodes) {
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
return parentPath.insertAfter(nodes.map(node => { return parentPath.insertAfter(nodes.map(node => {
return t().isExpression(node) ? t().expressionStatement(node) : node; return t.isExpression(node) ? t.expressionStatement(node) : node;
})); }));
} else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") { } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
if (this.node) { if (this.node) {
@@ -121,8 +115,8 @@ function insertAfter(nodes) {
} }
const temp = scope.generateDeclaredUidIdentifier(); const temp = scope.generateDeclaredUidIdentifier();
nodes.unshift(t().expressionStatement(t().assignmentExpression("=", t().cloneNode(temp), this.node))); nodes.unshift(t.expressionStatement(t.assignmentExpression("=", t.cloneNode(temp), this.node)));
nodes.push(t().expressionStatement(t().cloneNode(temp))); nodes.push(t.expressionStatement(t.cloneNode(temp)));
} }
return this.replaceExpressionWithStatements(nodes); return this.replaceExpressionWithStatements(nodes);
@@ -130,7 +124,7 @@ function insertAfter(nodes) {
return this._containerInsertAfter(nodes); return this._containerInsertAfter(nodes);
} else if (this.isStatementOrBlock()) { } else if (this.isStatementOrBlock()) {
const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null); const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : [])); this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : []));
return this.pushContainer("body", nodes); return this.pushContainer("body", nodes);
} else { } else {
throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");

View File

@@ -12,6 +12,8 @@ exports._assertUnremoved = _assertUnremoved;
var _removalHooks = require("./lib/removal-hooks"); var _removalHooks = require("./lib/removal-hooks");
var _index = require("./index");
function remove() { function remove() {
this._assertUnremoved(); this._assertUnremoved();
@@ -53,8 +55,7 @@ function _remove() {
} }
function _markRemoved() { function _markRemoved() {
this.shouldSkip = true; this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
this.removed = true;
this.node = null; this.node = null;
} }

View File

@@ -10,41 +10,19 @@ exports._replaceWith = _replaceWith;
exports.replaceExpressionWithStatements = replaceExpressionWithStatements; exports.replaceExpressionWithStatements = replaceExpressionWithStatements;
exports.replaceInline = replaceInline; exports.replaceInline = replaceInline;
function _codeFrame() { var _codeFrame = require("@babel/code-frame");
const data = require("@babel/code-frame");
_codeFrame = function () {
return data;
};
return data;
}
var _index = _interopRequireDefault(require("../index")); var _index = _interopRequireDefault(require("../index"));
var _index2 = _interopRequireDefault(require("./index")); var _index2 = _interopRequireDefault(require("./index"));
function _parser() { var _parser = require("@babel/parser");
const data = require("@babel/parser");
_parser = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
}
function t() { function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -67,7 +45,7 @@ const hoistVariablesVisitor = {
for (const declar of path.node.declarations) { for (const declar of path.node.declarations) {
if (declar.init) { if (declar.init) {
exprs.push(t().expressionStatement(t().assignmentExpression("=", declar.id, declar.init))); exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
} }
} }
@@ -79,8 +57,8 @@ const hoistVariablesVisitor = {
function replaceWithMultiple(nodes) { function replaceWithMultiple(nodes) {
this.resync(); this.resync();
nodes = this._verifyNodeList(nodes); nodes = this._verifyNodeList(nodes);
t().inheritLeadingComments(nodes[0], this.node); t.inheritLeadingComments(nodes[0], this.node);
t().inheritTrailingComments(nodes[nodes.length - 1], this.node); t.inheritTrailingComments(nodes[nodes.length - 1], this.node);
this.node = this.container[this.key] = null; this.node = this.container[this.key] = null;
const paths = this.insertAfter(nodes); const paths = this.insertAfter(nodes);
@@ -98,12 +76,12 @@ function replaceWithSourceString(replacement) {
try { try {
replacement = `(${replacement})`; replacement = `(${replacement})`;
replacement = (0, _parser().parse)(replacement); replacement = (0, _parser.parse)(replacement);
} catch (err) { } catch (err) {
const loc = err.loc; const loc = err.loc;
if (loc) { if (loc) {
err.message += " - make sure this is an expression.\n" + (0, _codeFrame().codeFrameColumns)(replacement, { err.message += " - make sure this is an expression.\n" + (0, _codeFrame.codeFrameColumns)(replacement, {
start: { start: {
line: loc.line, line: loc.line,
column: loc.column + 1 column: loc.column + 1
@@ -141,7 +119,7 @@ function replaceWith(replacement) {
return [this]; return [this];
} }
if (this.isProgram() && !t().isProgram(replacement)) { if (this.isProgram() && !t.isProgram(replacement)) {
throw new Error("You can only replace a Program root node with another Program node"); throw new Error("You can only replace a Program root node with another Program node");
} }
@@ -155,14 +133,14 @@ function replaceWith(replacement) {
let nodePath = ""; let nodePath = "";
if (this.isNodeType("Statement") && t().isExpression(replacement)) { if (this.isNodeType("Statement") && t.isExpression(replacement)) {
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) { if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) {
replacement = t().expressionStatement(replacement); replacement = t.expressionStatement(replacement);
nodePath = "expression"; nodePath = "expression";
} }
} }
if (this.isNodeType("Expression") && t().isStatement(replacement)) { if (this.isNodeType("Expression") && t.isStatement(replacement)) {
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) { if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
return this.replaceExpressionWithStatements([replacement]); return this.replaceExpressionWithStatements([replacement]);
} }
@@ -171,8 +149,8 @@ function replaceWith(replacement) {
const oldNode = this.node; const oldNode = this.node;
if (oldNode) { if (oldNode) {
t().inheritsComments(replacement, oldNode); t.inheritsComments(replacement, oldNode);
t().removeComments(oldNode); t.removeComments(oldNode);
} }
this._replaceWith(replacement); this._replaceWith(replacement);
@@ -189,9 +167,9 @@ function _replaceWith(node) {
} }
if (this.inList) { if (this.inList) {
t().validate(this.parent, this.key, [node]); t.validate(this.parent, this.key, [node]);
} else { } else {
t().validate(this.parent, this.key, node); t.validate(this.parent, this.key, node);
} }
this.debug(`Replace with ${node && node.type}`); this.debug(`Replace with ${node && node.type}`);
@@ -200,7 +178,7 @@ function _replaceWith(node) {
function replaceExpressionWithStatements(nodes) { function replaceExpressionWithStatements(nodes) {
this.resync(); this.resync();
const toSequenceExpression = t().toSequenceExpression(nodes, this.scope); const toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
if (toSequenceExpression) { if (toSequenceExpression) {
return this.replaceWith(toSequenceExpression)[0].get("expressions"); return this.replaceWith(toSequenceExpression)[0].get("expressions");
@@ -208,8 +186,8 @@ function replaceExpressionWithStatements(nodes) {
const functionParent = this.getFunctionParent(); const functionParent = this.getFunctionParent();
const isParentAsync = functionParent && functionParent.is("async"); const isParentAsync = functionParent && functionParent.is("async");
const container = t().arrowFunctionExpression([], t().blockStatement(nodes)); const container = t.arrowFunctionExpression([], t.blockStatement(nodes));
this.replaceWith(t().callExpression(container, [])); this.replaceWith(t.callExpression(container, []));
this.traverse(hoistVariablesVisitor); this.traverse(hoistVariablesVisitor);
const completionRecords = this.get("callee").getCompletionRecords(); const completionRecords = this.get("callee").getCompletionRecords();
@@ -223,24 +201,24 @@ function replaceExpressionWithStatements(nodes) {
if (!uid) { if (!uid) {
const callee = this.get("callee"); const callee = this.get("callee");
uid = callee.scope.generateDeclaredUidIdentifier("ret"); uid = callee.scope.generateDeclaredUidIdentifier("ret");
callee.get("body").pushContainer("body", t().returnStatement(t().cloneNode(uid))); callee.get("body").pushContainer("body", t.returnStatement(t.cloneNode(uid)));
loop.setData("expressionReplacementReturnUid", uid); loop.setData("expressionReplacementReturnUid", uid);
} else { } else {
uid = t().identifier(uid.name); uid = t.identifier(uid.name);
} }
path.get("expression").replaceWith(t().assignmentExpression("=", t().cloneNode(uid), path.node.expression)); path.get("expression").replaceWith(t.assignmentExpression("=", t.cloneNode(uid), path.node.expression));
} else { } else {
path.replaceWith(t().returnStatement(path.node.expression)); path.replaceWith(t.returnStatement(path.node.expression));
} }
} }
const callee = this.get("callee"); const callee = this.get("callee");
callee.arrowFunctionToExpression(); callee.arrowFunctionToExpression();
if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t().FUNCTION_TYPES)) { if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t.FUNCTION_TYPES)) {
callee.set("async", true); callee.set("async", true);
this.replaceWith(t().awaitExpression(this.node)); this.replaceWith(t.awaitExpression(this.node));
} }
return callee.get("body.body"); return callee.get("body.body");

View File

@@ -5,70 +5,32 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = void 0; exports.default = void 0;
function _includes() { var _includes = _interopRequireDefault(require("lodash/includes"));
const data = _interopRequireDefault(require("lodash/includes"));
_includes = function () { var _repeat = _interopRequireDefault(require("lodash/repeat"));
return data;
};
return data;
}
function _repeat() {
const data = _interopRequireDefault(require("lodash/repeat"));
_repeat = function () {
return data;
};
return data;
}
var _renamer = _interopRequireDefault(require("./lib/renamer")); var _renamer = _interopRequireDefault(require("./lib/renamer"));
var _index = _interopRequireDefault(require("../index")); var _index = _interopRequireDefault(require("../index"));
function _defaults() { var _defaults = _interopRequireDefault(require("lodash/defaults"));
const data = _interopRequireDefault(require("lodash/defaults"));
_defaults = function () {
return data;
};
return data;
}
var _binding = _interopRequireDefault(require("./binding")); var _binding = _interopRequireDefault(require("./binding"));
function _globals() { var _globals = _interopRequireDefault(require("globals"));
const data = _interopRequireDefault(require("globals"));
_globals = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
var _cache = require("../cache"); var _cache = require("../cache");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function gatherNodeParts(node, parts) { function gatherNodeParts(node, parts) {
if (t().isModuleDeclaration(node)) { if (t.isModuleDeclaration(node)) {
if (node.source) { if (node.source) {
gatherNodeParts(node.source, parts); gatherNodeParts(node.source, parts);
} else if (node.specifiers && node.specifiers.length) { } else if (node.specifiers && node.specifiers.length) {
@@ -78,33 +40,33 @@ function gatherNodeParts(node, parts) {
} else if (node.declaration) { } else if (node.declaration) {
gatherNodeParts(node.declaration, parts); gatherNodeParts(node.declaration, parts);
} }
} else if (t().isModuleSpecifier(node)) { } else if (t.isModuleSpecifier(node)) {
gatherNodeParts(node.local, parts); gatherNodeParts(node.local, parts);
} else if (t().isMemberExpression(node)) { } else if (t.isMemberExpression(node)) {
gatherNodeParts(node.object, parts); gatherNodeParts(node.object, parts);
gatherNodeParts(node.property, parts); gatherNodeParts(node.property, parts);
} else if (t().isIdentifier(node)) { } else if (t.isIdentifier(node)) {
parts.push(node.name); parts.push(node.name);
} else if (t().isLiteral(node)) { } else if (t.isLiteral(node)) {
parts.push(node.value); parts.push(node.value);
} else if (t().isCallExpression(node)) { } else if (t.isCallExpression(node)) {
gatherNodeParts(node.callee, parts); gatherNodeParts(node.callee, parts);
} else if (t().isObjectExpression(node) || t().isObjectPattern(node)) { } else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
for (const prop of node.properties) { for (const prop of node.properties) {
gatherNodeParts(prop.key || prop.argument, parts); gatherNodeParts(prop.key || prop.argument, parts);
} }
} else if (t().isPrivateName(node)) { } else if (t.isPrivateName(node)) {
gatherNodeParts(node.id, parts); gatherNodeParts(node.id, parts);
} else if (t().isThisExpression(node)) { } else if (t.isThisExpression(node)) {
parts.push("this"); parts.push("this");
} else if (t().isSuper(node)) { } else if (t.isSuper(node)) {
parts.push("super"); parts.push("super");
} }
} }
const collectorVisitor = { const collectorVisitor = {
For(path) { For(path) {
for (const key of t().FOR_INIT_KEYS) { for (const key of t.FOR_INIT_KEYS) {
const declar = path.get(key); const declar = path.get(key);
if (declar.isVar()) { if (declar.isVar()) {
@@ -145,14 +107,14 @@ const collectorVisitor = {
} = path; } = path;
const declar = node.declaration; const declar = node.declaration;
if (t().isClassDeclaration(declar) || t().isFunctionDeclaration(declar)) { if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
const id = declar.id; const id = declar.id;
if (!id) return; if (!id) return;
const binding = scope.getBinding(id.name); const binding = scope.getBinding(id.name);
if (binding) binding.reference(path); if (binding) binding.reference(path);
} else if (t().isVariableDeclaration(declar)) { } else if (t.isVariableDeclaration(declar)) {
for (const decl of declar.declarations) { for (const decl of declar.declarations) {
for (const name of Object.keys(t().getBindingIdentifiers(decl))) { for (const name of Object.keys(t.getBindingIdentifiers(decl))) {
const binding = scope.getBinding(name); const binding = scope.getBinding(name);
if (binding) binding.reference(path); if (binding) binding.reference(path);
} }
@@ -249,15 +211,15 @@ class Scope {
this.push({ this.push({
id id
}); });
return t().cloneNode(id); return t.cloneNode(id);
} }
generateUidIdentifier(name) { generateUidIdentifier(name) {
return t().identifier(this.generateUid(name)); return t.identifier(this.generateUid(name));
} }
generateUid(name = "temp") { generateUid(name = "temp") {
name = t().toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, ""); name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
let uid; let uid;
let i = 0; let i = 0;
@@ -281,11 +243,11 @@ class Scope {
generateUidBasedOnNode(parent, defaultName) { generateUidBasedOnNode(parent, defaultName) {
let node = parent; let node = parent;
if (t().isAssignmentExpression(parent)) { if (t.isAssignmentExpression(parent)) {
node = parent.left; node = parent.left;
} else if (t().isVariableDeclarator(parent)) { } else if (t.isVariableDeclarator(parent)) {
node = parent.id; node = parent.id;
} else if (t().isObjectProperty(node) || t().isObjectMethod(node)) { } else if (t.isObjectProperty(node) || t.isObjectMethod(node)) {
node = node.key; node = node.key;
} }
@@ -297,15 +259,15 @@ class Scope {
} }
generateUidIdentifierBasedOnNode(parent, defaultName) { generateUidIdentifierBasedOnNode(parent, defaultName) {
return t().identifier(this.generateUidBasedOnNode(parent, defaultName)); return t.identifier(this.generateUidBasedOnNode(parent, defaultName));
} }
isStatic(node) { isStatic(node) {
if (t().isThisExpression(node) || t().isSuper(node)) { if (t.isThisExpression(node) || t.isSuper(node)) {
return true; return true;
} }
if (t().isIdentifier(node)) { if (t.isIdentifier(node)) {
const binding = this.getBinding(node.name); const binding = this.getBinding(node.name);
if (binding) { if (binding) {
@@ -328,7 +290,7 @@ class Scope {
this.push({ this.push({
id id
}); });
return t().cloneNode(id); return t.cloneNode(id);
} }
return id; return id;
@@ -362,7 +324,7 @@ class Scope {
} }
dump() { dump() {
const sep = (0, _repeat().default)("-", 60); const sep = (0, _repeat.default)("-", 60);
console.log(sep); console.log(sep);
let scope = this; let scope = this;
@@ -384,7 +346,7 @@ class Scope {
} }
toArray(node, i) { toArray(node, i) {
if (t().isIdentifier(node)) { if (t.isIdentifier(node)) {
const binding = this.getBinding(node.name); const binding = this.getBinding(node.name);
if (binding && binding.constant && binding.path.isGenericType("Array")) { if (binding && binding.constant && binding.path.isGenericType("Array")) {
@@ -392,14 +354,14 @@ class Scope {
} }
} }
if (t().isArrayExpression(node)) { if (t.isArrayExpression(node)) {
return node; return node;
} }
if (t().isIdentifier(node, { if (t.isIdentifier(node, {
name: "arguments" name: "arguments"
})) { })) {
return t().callExpression(t().memberExpression(t().memberExpression(t().memberExpression(t().identifier("Array"), t().identifier("prototype")), t().identifier("slice")), t().identifier("call")), [node]); return t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("Array"), t.identifier("prototype")), t.identifier("slice")), t.identifier("call")), [node]);
} }
let helperName; let helperName;
@@ -408,13 +370,13 @@ class Scope {
if (i === true) { if (i === true) {
helperName = "toConsumableArray"; helperName = "toConsumableArray";
} else if (i) { } else if (i) {
args.push(t().numericLiteral(i)); args.push(t.numericLiteral(i));
helperName = "slicedToArray"; helperName = "slicedToArray";
} else { } else {
helperName = "toArray"; helperName = "toArray";
} }
return t().callExpression(this.hub.addHelper(helperName), args); return t.callExpression(this.hub.addHelper(helperName), args);
} }
hasLabel(name) { hasLabel(name) {
@@ -460,11 +422,7 @@ class Scope {
} }
buildUndefinedNode() { buildUndefinedNode() {
if (this.hasBinding("undefined")) { return t.unaryExpression("void", t.numericLiteral(0), true);
return t().unaryExpression("void", t().numericLiteral(0), true);
} else {
return t().identifier("undefined");
}
} }
registerConstantViolation(path) { registerConstantViolation(path) {
@@ -552,56 +510,56 @@ class Scope {
} }
isPure(node, constantsOnly) { isPure(node, constantsOnly) {
if (t().isIdentifier(node)) { if (t.isIdentifier(node)) {
const binding = this.getBinding(node.name); const binding = this.getBinding(node.name);
if (!binding) return false; if (!binding) return false;
if (constantsOnly) return binding.constant; if (constantsOnly) return binding.constant;
return true; return true;
} else if (t().isClass(node)) { } else if (t.isClass(node)) {
if (node.superClass && !this.isPure(node.superClass, constantsOnly)) { if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {
return false; return false;
} }
return this.isPure(node.body, constantsOnly); return this.isPure(node.body, constantsOnly);
} else if (t().isClassBody(node)) { } else if (t.isClassBody(node)) {
for (const method of node.body) { for (const method of node.body) {
if (!this.isPure(method, constantsOnly)) return false; if (!this.isPure(method, constantsOnly)) return false;
} }
return true; return true;
} else if (t().isBinary(node)) { } else if (t.isBinary(node)) {
return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly); return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
} else if (t().isArrayExpression(node)) { } else if (t.isArrayExpression(node)) {
for (const elem of node.elements) { for (const elem of node.elements) {
if (!this.isPure(elem, constantsOnly)) return false; if (!this.isPure(elem, constantsOnly)) return false;
} }
return true; return true;
} else if (t().isObjectExpression(node)) { } else if (t.isObjectExpression(node)) {
for (const prop of node.properties) { for (const prop of node.properties) {
if (!this.isPure(prop, constantsOnly)) return false; if (!this.isPure(prop, constantsOnly)) return false;
} }
return true; return true;
} else if (t().isClassMethod(node)) { } else if (t.isClassMethod(node)) {
if (node.computed && !this.isPure(node.key, constantsOnly)) return false; if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
if (node.kind === "get" || node.kind === "set") return false; if (node.kind === "get" || node.kind === "set") return false;
return true; return true;
} else if (t().isProperty(node)) { } else if (t.isProperty(node)) {
if (node.computed && !this.isPure(node.key, constantsOnly)) return false; if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
return this.isPure(node.value, constantsOnly); return this.isPure(node.value, constantsOnly);
} else if (t().isUnaryExpression(node)) { } else if (t.isUnaryExpression(node)) {
return this.isPure(node.argument, constantsOnly); return this.isPure(node.argument, constantsOnly);
} else if (t().isTaggedTemplateExpression(node)) { } else if (t.isTaggedTemplateExpression(node)) {
return t().matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly); return t.matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
} else if (t().isTemplateLiteral(node)) { } else if (t.isTemplateLiteral(node)) {
for (const expression of node.expressions) { for (const expression of node.expressions) {
if (!this.isPure(expression, constantsOnly)) return false; if (!this.isPure(expression, constantsOnly)) return false;
} }
return true; return true;
} else { } else {
return t().isPureish(node); return t.isPureish(node);
} }
} }
@@ -640,20 +598,20 @@ class Scope {
this.data = Object.create(null); this.data = Object.create(null);
if (path.isLoop()) { if (path.isLoop()) {
for (const key of t().FOR_INIT_KEYS) { for (const key of t.FOR_INIT_KEYS) {
const node = path.get(key); const node = path.get(key);
if (node.isBlockScoped()) this.registerBinding(node.node.kind, node); if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
} }
} }
if (path.isFunctionExpression() && path.has("id")) { if (path.isFunctionExpression() && path.has("id")) {
if (!path.get("id").node[t().NOT_LOCAL_BINDING]) { if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
this.registerBinding("local", path.get("id"), path); this.registerBinding("local", path.get("id"), path);
} }
} }
if (path.isClassExpression() && path.has("id")) { if (path.isClassExpression() && path.has("id")) {
if (!path.get("id").node[t().NOT_LOCAL_BINDING]) { if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
this.registerBinding("local", path); this.registerBinding("local", path);
} }
} }
@@ -732,13 +690,13 @@ class Scope {
let declarPath = !unique && path.getData(dataKey); let declarPath = !unique && path.getData(dataKey);
if (!declarPath) { if (!declarPath) {
const declar = t().variableDeclaration(kind, []); const declar = t.variableDeclaration(kind, []);
declar._blockHoist = blockHoist; declar._blockHoist = blockHoist;
[declarPath] = path.unshiftContainer("body", [declar]); [declarPath] = path.unshiftContainer("body", [declar]);
if (!unique) path.setData(dataKey, declarPath); if (!unique) path.setData(dataKey, declarPath);
} }
const declarator = t().variableDeclarator(opts.id, opts.init); const declarator = t.variableDeclarator(opts.id, opts.init);
declarPath.node.declarations.push(declarator); declarPath.node.declarations.push(declarator);
this.registerBinding(kind, declarPath.get("declarations").pop()); this.registerBinding(kind, declarPath.get("declarations").pop());
} }
@@ -784,7 +742,7 @@ class Scope {
let scope = this; let scope = this;
do { do {
(0, _defaults().default)(ids, scope.bindings); (0, _defaults.default)(ids, scope.bindings);
scope = scope.parent; scope = scope.parent;
} while (scope); } while (scope);
@@ -846,8 +804,8 @@ class Scope {
if (this.hasOwnBinding(name)) return true; if (this.hasOwnBinding(name)) return true;
if (this.parentHasBinding(name, noGlobals)) return true; if (this.parentHasBinding(name, noGlobals)) return true;
if (this.hasUid(name)) return true; if (this.hasUid(name)) return true;
if (!noGlobals && (0, _includes().default)(Scope.globals, name)) return true; if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true;
if (!noGlobals && (0, _includes().default)(Scope.contextVariables, name)) return true; if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true;
return false; return false;
} }
@@ -888,5 +846,5 @@ class Scope {
} }
exports.default = Scope; exports.default = Scope;
Scope.globals = Object.keys(_globals().default.builtin); Scope.globals = Object.keys(_globals.default.builtin);
Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"]; Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];

View File

@@ -7,27 +7,13 @@ exports.default = void 0;
var _binding = _interopRequireDefault(require("../binding")); var _binding = _interopRequireDefault(require("../binding"));
function _helperSplitExportDeclaration() { var _helperSplitExportDeclaration = _interopRequireDefault(require("@babel/helper-split-export-declaration"));
const data = _interopRequireDefault(require("@babel/helper-split-export-declaration"));
_helperSplitExportDeclaration = function () { var t = _interopRequireWildcard(require("@babel/types"));
return data;
};
return data; function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
}
function t() { function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -74,27 +60,27 @@ class Renamer {
return; return;
} }
(0, _helperSplitExportDeclaration().default)(maybeExportDeclar); (0, _helperSplitExportDeclaration.default)(maybeExportDeclar);
} }
maybeConvertFromClassFunctionDeclaration(path) { maybeConvertFromClassFunctionDeclaration(path) {
return; return;
if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return; if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
if (this.binding.kind !== "hoisted") return; if (this.binding.kind !== "hoisted") return;
path.node.id = t().identifier(this.oldName); path.node.id = t.identifier(this.oldName);
path.node._blockHoist = 3; path.node._blockHoist = 3;
path.replaceWith(t().variableDeclaration("let", [t().variableDeclarator(t().identifier(this.newName), t().toExpression(path.node))])); path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(this.newName), t.toExpression(path.node))]));
} }
maybeConvertFromClassFunctionExpression(path) { maybeConvertFromClassFunctionExpression(path) {
return; return;
if (!path.isFunctionExpression() && !path.isClassExpression()) return; if (!path.isFunctionExpression() && !path.isClassExpression()) return;
if (this.binding.kind !== "local") return; if (this.binding.kind !== "local") return;
path.node.id = t().identifier(this.oldName); path.node.id = t.identifier(this.oldName);
this.binding.scope.parent.push({ this.binding.scope.parent.push({
id: t().identifier(this.newName) id: t.identifier(this.newName)
}); });
path.replaceWith(t().assignmentExpression("=", t().identifier(this.newName), path.node)); path.replaceWith(t.assignmentExpression("=", t.identifier(this.newName), path.node));
} }
rename(block) { rename(block) {

Some files were not shown because too many files have changed in this diff Show More