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.

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

@@ -1,81 +1,140 @@
# `@actions/core` # `@actions/core`
> Core functions for setting results, logging, registering secrets and exporting variables across actions > Core functions for setting results, logging, registering secrets and exporting variables across actions
## 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');
// typescript
const myInput = core.getInput('inputName', { required: true }); import * as core from '@actions/core';
```
// Do stuff
#### Inputs/Outputs
core.setOutput('outputKey', 'outputVal');
``` 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.
#### Exporting variables/secrets ```js
const myInput = core.getInput('inputName', { required: true });
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:
core.setOutput('outputKey', 'outputVal');
``` ```
const core = require('@actions/core');
#### Exporting variables
// Do stuff
Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.
core.exportVariable('envVar', 'Val');
core.exportSecret('secretVar', variableWithSecretValue); ```js
``` core.exportVariable('envVar', 'Val');
```
#### PATH Manipulation
#### Setting a secret
You can explicitly add items to the path for all remaining steps in a workflow:
Setting a secret registers the secret with the runner to ensure it is masked in logs.
```
const core = require('@actions/core'); ```js
core.setSecret('myPassword');
core.addPath('pathToTool'); ```
```
#### PATH Manipulation
#### Exit codes
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.
You should use this library to set the failing exit code for your action:
```js
``` core.addPath('/path/to/mytool');
const core = require('@actions/core'); ```
try { #### Exit codes
// Do stuff
} 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.
catch (err) {
// setFailed logs the message and sets a failing exit code ```js
core.setFailed(`Action failed with error ${err}`); const core = require('@actions/core');
}
try {
``` // Do stuff
}
#### Logging catch (err) {
// setFailed logs the message and sets a failing exit code
Finally, this library provides some utilities for logging: core.setFailed(`Action failed with error ${err}`);
}
```
const core = require('@actions/core'); Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
const myInput = core.getInput('input'); ```
try {
core.debug('Inside try block'); #### Logging
if (!myInput) { 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).
core.warning('myInput wasnt set');
} ```js
const core = require('@actions/core');
// Do stuff
} const myInput = core.getInput('input');
catch (err) { try {
core.error('Error ${err}, action may still succeed though'); core.debug('Inside try block');
}
``` if (!myInput) {
core.warning('myInput was not set');
}
// Do stuff
}
catch (err) {
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

@@ -1,16 +1,16 @@
interface CommandProperties { interface CommandProperties {
[key: string]: string; [key: string]: string;
} }
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* 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

@@ -1,66 +1,66 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os"); const os = require("os");
/** /**
* Commands * Commands
* *
* Command Format: * Command Format:
* ##[name key=value;key=value]message * ##[name key=value;key=value]message
* *
* 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) {
command = 'missing.command'; command = 'missing.command';
} }
this.command = command; this.command = command;
this.properties = properties; this.properties = properties;
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) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
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 || ''}`;
cmdStr += escapeData(message); cmdStr += escapeData(message);
return cmdStr; return cmdStr;
} }
} }
function escapeData(s) { function escapeData(s) {
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
} }
function escape(s) { function escape(s) {
return s return s
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
.replace(/]/g, '%5D') .replace(/]/g, '%5D')
.replace(/;/g, '%3B'); .replace(/;/g, '%3B');
} }
//# sourceMappingURL=command.js.map //# sourceMappingURL=command.js.map

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

@@ -1,73 +1,112 @@
/** /**
* Interface for getInput options * Interface for getInput options
*/ */
export interface InputOptions { export interface InputOptions {
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ /** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean; required?: boolean;
} }
/** /**
* The code to exit an action * The code to exit an action
*/ */
export declare enum ExitCode { export declare enum ExitCode {
/** /**
* A code indicating that the action was successful * A code indicating that the action was successful
*/ */
Success = 0, Success = 0,
/** /**
* A code indicating that the action was a failure * A code indicating that the action was a failure
*/ */
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 setSecret(secret: string): void;
export declare function exportSecret(name: string, val: 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 */
*/ export declare function addPath(inputPath: string): void;
export declare function addPath(inputPath: string): void; /**
/** * Gets the value of an input. The value is also trimmed.
* Gets the value of an input. The value is also trimmed. *
* * @param name name of the input to get
* @param name name of the input to get * @param options optional. See InputOptions.
* @param options optional. See InputOptions. * @returns string
* @returns string */
*/ export declare function getInput(name: string, options?: InputOptions): string;
export declare function getInput(name: string, options?: InputOptions): string; /**
/** * Sets the value of an output.
* Sets the value of an output. *
* * @param name name of the output to set
* @param name name of the output to set * @param value value to store
* @param value value to store */
*/ export declare function setOutput(name: string, value: string): void;
export declare function setOutput(name: string, value: string): void; /**
/** * Sets the action status to failed.
* Sets the action status to failed. * When the action exits it will be with an exit code of 1
* When the action exits it will be with an exit code of 1 * @param message add error issue message
* @param message add error issue message */
*/ export declare function setFailed(message: string): void;
export declare function setFailed(message: string): void; /**
/** * Writes debug message to user log
* Writes debug message to user log * @param message debug message
* @param message debug message */
*/ export declare function debug(message: string): void;
export declare function debug(message: string): void; /**
/** * Adds an error issue
* Adds an error issue * @param message error issue message
* @param message error issue message */
*/ export declare function error(message: string): void;
export declare function error(message: string): void; /**
/** * Adds an warning issue
* Adds an warning issue * @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,116 +1,195 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
const command_1 = require("./command"); function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
const path = require("path"); return new (P || (P = Promise))(function (resolve, reject) {
/** function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
* The code to exit an action 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); }
var ExitCode; step((generator = generator.apply(thisArg, _arguments || [])).next());
(function (ExitCode) { });
/** };
* A code indicating that the action was successful Object.defineProperty(exports, "__esModule", { value: true });
*/ const command_1 = require("./command");
ExitCode[ExitCode["Success"] = 0] = "Success"; const os = require("os");
/** const path = require("path");
* A code indicating that the action was a failure /**
*/ * The code to exit an action
ExitCode[ExitCode["Failure"] = 1] = "Failure"; */
})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); var ExitCode;
//----------------------------------------------------------------------- (function (ExitCode) {
// Variables /**
//----------------------------------------------------------------------- * A code indicating that the action was successful
/** */
* sets env variable for this action and future actions in the job ExitCode[ExitCode["Success"] = 0] = "Success";
* @param name the name of the variable to set /**
* @param val the value of the variable * A code indicating that the action was a failure
*/ */
function exportVariable(name, val) { ExitCode[ExitCode["Failure"] = 1] = "Failure";
process.env[name] = val; })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
command_1.issueCommand('set-env', { name }, val); //-----------------------------------------------------------------------
} // Variables
exports.exportVariable = exportVariable; //-----------------------------------------------------------------------
/** /**
* exports the variable and registers a secret which will get masked from logs * 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 value of the secret * @param val the value of the variable
*/ */
function exportSecret(name, val) { function exportVariable(name, val) {
exportVariable(name, val); process.env[name] = val;
command_1.issueCommand('set-secret', {}, val); command_1.issueCommand('set-env', { name }, val);
} }
exports.exportSecret = exportSecret; exports.exportVariable = exportVariable;
/** /**
* Prepends inputPath to the PATH (for this action and future actions) * Registers a secret which will get masked from logs
* @param inputPath * @param secret value of the secret
*/ */
function addPath(inputPath) { function setSecret(secret) {
command_1.issueCommand('add-path', {}, inputPath); command_1.issueCommand('add-mask', {}, secret);
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; }
} exports.setSecret = setSecret;
exports.addPath = addPath; /**
/** * Prepends inputPath to the PATH (for this action and future actions)
* Gets the value of an input. The value is also trimmed. * @param inputPath
* */
* @param name name of the input to get function addPath(inputPath) {
* @param options optional. See InputOptions. command_1.issueCommand('add-path', {}, inputPath);
* @returns string process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
*/ }
function getInput(name, options) { exports.addPath = addPath;
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; /**
if (options && options.required && !val) { * Gets the value of an input. The value is also trimmed.
throw new Error(`Input required and not supplied: ${name}`); *
} * @param name name of the input to get
return val.trim(); * @param options optional. See InputOptions.
} * @returns string
exports.getInput = getInput; */
/** function getInput(name, options) {
* Sets the value of an output. const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
* if (options && options.required && !val) {
* @param name name of the output to set throw new Error(`Input required and not supplied: ${name}`);
* @param value value to store }
*/ return val.trim();
function setOutput(name, value) { }
command_1.issueCommand('set-output', { name }, value); exports.getInput = getInput;
} /**
exports.setOutput = setOutput; * Sets the value of an output.
//----------------------------------------------------------------------- *
// Results * @param name name of the output to set
//----------------------------------------------------------------------- * @param value value to store
/** */
* Sets the action status to failed. function setOutput(name, value) {
* When the action exits it will be with an exit code of 1 command_1.issueCommand('set-output', { name }, value);
* @param message add error issue message }
*/ exports.setOutput = setOutput;
function setFailed(message) { //-----------------------------------------------------------------------
process.exitCode = ExitCode.Failure; // Results
error(message); //-----------------------------------------------------------------------
} /**
exports.setFailed = setFailed; * Sets the action status to failed.
//----------------------------------------------------------------------- * When the action exits it will be with an exit code of 1
// Logging Commands * @param message add error issue message
//----------------------------------------------------------------------- */
/** function setFailed(message) {
* Writes debug message to user log process.exitCode = ExitCode.Failure;
* @param message debug message error(message);
*/ }
function debug(message) { exports.setFailed = setFailed;
command_1.issueCommand('debug', {}, message); //-----------------------------------------------------------------------
} // Logging Commands
exports.debug = debug; //-----------------------------------------------------------------------
/** /**
* Adds an error issue * Writes debug message to user log
* @param message error issue message * @param message debug message
*/ */
function error(message) { function debug(message) {
command_1.issue('error', message); command_1.issueCommand('debug', {}, message);
} }
exports.error = error; exports.debug = debug;
/** /**
* Adds an warning issue * Adds an error issue
* @param message warning issue message * @param message error issue message
*/ */
function warning(message) { function error(message) {
command_1.issue('warning', message); command_1.issue('error', message);
} }
exports.warning = warning; exports.error = error;
/**
* Adds an warning issue
* @param message warning issue message
*/
function warning(message) {
command_1.issue('warning', message);
}
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"
} }

View File

@@ -1,7 +1,7 @@
Copyright 2019 GitHub 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: 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 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. 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.

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

@@ -1,60 +1,60 @@
# `@actions/exec` # `@actions/exec`
## Usage ## Usage
#### Basic #### Basic
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');
``` ```
#### Args #### Args
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']);
``` ```
#### Output/options #### Output/options
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 = {
stdout: (data: Buffer) => { stdout: (data: Buffer) => {
myOutput += data.toString(); myOutput += data.toString();
}, },
stderr: (data: Buffer) => { stderr: (data: Buffer) => {
myError += data.toString(); myError += data.toString();
} }
}; };
options.cwd = './lib'; options.cwd = './lib';
await exec.exec('node', ['index.js', 'foo=bar'], options); await exec.exec('node', ['index.js', 'foo=bar'], options);
``` ```
#### Exec tools not in the PATH #### Exec tools 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: 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');
const pythonPath: string = await io.which('python', true) const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']); await exec.exec(`"${pythonPath}"`, ['main.py']);
``` ```

View File

@@ -1,12 +1,12 @@
import * as im from './interfaces'; import * as im from './interfaces';
/** /**
* Exec a command. * Exec a command.
* Output will be streamed to the live console. * Output will be streamed to the live console.
* Returns promise with return code * Returns promise with return code
* *
* @param commandLine command to execute (can include additional args). Must be correctly escaped. * @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib. * @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions * @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code * @returns Promise<number> exit code
*/ */
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>; export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;

View File

@@ -1,36 +1,37 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } return new (P || (P = Promise))(function (resolve, reject) {
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
step((generator = generator.apply(thisArg, _arguments || [])).next()); 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 }); };
const tr = require("./toolrunner"); Object.defineProperty(exports, "__esModule", { value: true });
/** const tr = require("./toolrunner");
* Exec a command. /**
* Output will be streamed to the live console. * Exec a command.
* Returns promise with return code * Output will be streamed to the live console.
* * Returns promise with return code
* @param commandLine command to execute (can include additional args). Must be correctly escaped. *
* @param args optional arguments for tool. Escaping is handled by the lib. * @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param options optional exec options. See ExecOptions * @param args optional arguments for tool. Escaping is handled by the lib.
* @returns Promise<number> exit code * @param options optional exec options. See ExecOptions
*/ * @returns Promise<number> exit code
function exec(commandLine, args, options) { */
return __awaiter(this, void 0, void 0, function* () { function exec(commandLine, args, options) {
const commandArgs = tr.argStringToArray(commandLine); return __awaiter(this, void 0, void 0, function* () {
if (commandArgs.length === 0) { const commandArgs = tr.argStringToArray(commandLine);
throw new Error(`Parameter 'commandLine' cannot be null or empty.`); if (commandArgs.length === 0) {
} throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
// Path to tool to execute should be first arg }
const toolPath = commandArgs[0]; // Path to tool to execute should be first arg
args = commandArgs.slice(1).concat(args || []); const toolPath = commandArgs[0];
const runner = new tr.ToolRunner(toolPath, args, options); args = commandArgs.slice(1).concat(args || []);
return runner.exec(); const runner = new tr.ToolRunner(toolPath, args, options);
}); return runner.exec();
} });
exports.exec = exec; }
exports.exec = exec;
//# sourceMappingURL=exec.js.map //# sourceMappingURL=exec.js.map

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,35 +1,35 @@
/// <reference types="node" /> /// <reference types="node" />
import * as stream from 'stream'; import * as stream from 'stream';
/** /**
* Interface for exec options * Interface for exec options
*/ */
export interface ExecOptions { export interface ExecOptions {
/** optional working directory. defaults to current */ /** optional working directory. defaults to current */
cwd?: string; cwd?: string;
/** optional envvar dictionary. defaults to current process's env */ /** optional envvar dictionary. defaults to current process's env */
env?: { env?: {
[key: string]: string; [key: string]: string;
}; };
/** optional. defaults to false */ /** optional. defaults to false */
silent?: boolean; silent?: boolean;
/** optional out stream to use. Defaults to process.stdout */ /** optional out stream to use. Defaults to process.stdout */
outStream?: stream.Writable; outStream?: stream.Writable;
/** optional err stream to use. Defaults to process.stderr */ /** optional err stream to use. Defaults to process.stderr */
errStream?: stream.Writable; errStream?: stream.Writable;
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */ /** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
windowsVerbatimArguments?: boolean; windowsVerbatimArguments?: boolean;
/** optional. whether to fail if output to stderr. defaults to false */ /** optional. whether to fail if output to stderr. defaults to false */
failOnStdErr?: boolean; failOnStdErr?: boolean;
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */ /** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
ignoreReturnCode?: boolean; ignoreReturnCode?: boolean;
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */ /** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
delay?: number; delay?: number;
/** optional. Listeners for output. Callback functions that will be called on these events */ /** optional. Listeners for output. Callback functions that will be called on these events */
listeners?: { listeners?: {
stdout?: (data: Buffer) => void; stdout?: (data: Buffer) => void;
stderr?: (data: Buffer) => void; stderr?: (data: Buffer) => void;
stdline?: (data: string) => void; stdline?: (data: string) => void;
errline?: (data: string) => void; errline?: (data: string) => void;
debug?: (data: string) => void; debug?: (data: string) => void;
}; };
} }

View File

@@ -1,3 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map //# sourceMappingURL=interfaces.js.map

View File

@@ -1,37 +1,37 @@
/// <reference types="node" /> /// <reference types="node" />
import * as events from 'events'; import * as events from 'events';
import * as im from './interfaces'; import * as im from './interfaces';
export declare class ToolRunner extends events.EventEmitter { export declare class ToolRunner extends events.EventEmitter {
constructor(toolPath: string, args?: string[], options?: im.ExecOptions); constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
private toolPath; private toolPath;
private args; private args;
private options; private options;
private _debug; private _debug;
private _getCommandString; private _getCommandString;
private _processLineBuffer; private _processLineBuffer;
private _getSpawnFileName; private _getSpawnFileName;
private _getSpawnArgs; private _getSpawnArgs;
private _endsWith; private _endsWith;
private _isCmdFile; private _isCmdFile;
private _windowsQuoteCmdArg; private _windowsQuoteCmdArg;
private _uvQuoteCmdArg; private _uvQuoteCmdArg;
private _cloneExecOptions; private _cloneExecOptions;
private _getSpawnOptions; private _getSpawnOptions;
/** /**
* Exec a tool. * Exec a tool.
* Output will be streamed to the live console. * Output will be streamed to the live console.
* Returns promise with return code * Returns promise with return code
* *
* @param tool path to tool to exec * @param tool path to tool to exec
* @param options optional exec options. See ExecOptions * @param options optional exec options. See ExecOptions
* @returns number * @returns number
*/ */
exec(): Promise<number>; exec(): Promise<number>;
} }
/** /**
* Convert an arg string to an array of args. Handles escaping * Convert an arg string to an array of args. Handles escaping
* *
* @param argString string of arguments * @param argString string of arguments
* @returns string[] array of arguments * @returns string[] array of arguments
*/ */
export declare function argStringToArray(argString: string): string[]; export declare function argStringToArray(argString: string): string[];

File diff suppressed because it is too large Load Diff

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"
} }

12
node_modules/@actions/io/LICENSE.md generated vendored
View File

@@ -1,7 +1,7 @@
Copyright 2019 GitHub 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: 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 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. 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.

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

@@ -1,53 +1,53 @@
# `@actions/io` # `@actions/io`
> Core functions for cli filesystem scenarios > Core functions for cli filesystem scenarios
## Usage ## Usage
#### mkdir -p #### mkdir -p
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');
``` ```
#### cp/mv #### cp/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): 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
const options = { recursive: true, force: false } const options = { recursive: true, force: false }
await io.cp('path/to/directory', 'path/to/dest', options); await io.cp('path/to/directory', 'path/to/dest', options);
await io.mv('path/to/file', 'path/to/dest'); await io.mv('path/to/file', 'path/to/dest');
``` ```
#### rm -rf #### rm -rf
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');
await io.rmRF('path/to/file'); await io.rmRF('path/to/file');
``` ```
#### which #### 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). 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');
const pythonPath: string = await io.which('python', true) const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']); await exec.exec(`"${pythonPath}"`, ['main.py']);
``` ```

View File

@@ -1,29 +1,29 @@
/// <reference types="node" /> /// <reference types="node" />
import * as fs from 'fs'; import * as fs from 'fs';
export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, readlink: typeof fs.promises.readlink, rename: typeof fs.promises.rename, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink; export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, readlink: typeof fs.promises.readlink, rename: typeof fs.promises.rename, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink;
export declare const IS_WINDOWS: boolean; export declare const IS_WINDOWS: boolean;
export declare function exists(fsPath: string): Promise<boolean>; export declare function exists(fsPath: string): Promise<boolean>;
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>; export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
/** /**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
*/ */
export declare function isRooted(p: string): boolean; export declare function isRooted(p: string): boolean;
/** /**
* Recursively create a directory at `fsPath`. * Recursively create a directory at `fsPath`.
* *
* This implementation is optimistic, meaning it attempts to create the full * This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there. * path first, and backs up the path stack from there.
* *
* @param fsPath The path to create * @param fsPath The path to create
* @param maxDepth The maximum recursion depth * @param maxDepth The maximum recursion depth
* @param depth The current recursion depth * @param depth The current recursion depth
*/ */
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>; export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
/** /**
* Best effort attempt to determine whether a file exists and is executable. * Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check * @param filePath file path to check
* @param extensions additional file extensions to try * @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string. * @return if file exists and is executable, returns the file path. otherwise empty string.
*/ */
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>; export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;

View File

@@ -1,194 +1,195 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } return new (P || (P = Promise))(function (resolve, reject) {
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
step((generator = generator.apply(thisArg, _arguments || [])).next()); function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
}); step((generator = generator.apply(thisArg, _arguments || [])).next());
}; });
var _a; };
Object.defineProperty(exports, "__esModule", { value: true }); var _a;
const assert_1 = require("assert"); Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs"); const assert_1 = require("assert");
const path = require("path"); const fs = require("fs");
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; const path = require("path");
exports.IS_WINDOWS = process.platform === 'win32'; _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
function exists(fsPath) { exports.IS_WINDOWS = process.platform === 'win32';
return __awaiter(this, void 0, void 0, function* () { function exists(fsPath) {
try { return __awaiter(this, void 0, void 0, function* () {
yield exports.stat(fsPath); try {
} yield exports.stat(fsPath);
catch (err) { }
if (err.code === 'ENOENT') { catch (err) {
return false; if (err.code === 'ENOENT') {
} return false;
throw err; }
} throw err;
return true; }
}); return true;
} });
exports.exists = exists; }
function isDirectory(fsPath, useStat = false) { exports.exists = exists;
return __awaiter(this, void 0, void 0, function* () { function isDirectory(fsPath, useStat = false) {
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); return __awaiter(this, void 0, void 0, function* () {
return stats.isDirectory(); const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
}); return stats.isDirectory();
} });
exports.isDirectory = isDirectory; }
/** exports.isDirectory = isDirectory;
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: /**
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
*/ * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
function isRooted(p) { */
p = normalizeSeparators(p); function isRooted(p) {
if (!p) { p = normalizeSeparators(p);
throw new Error('isRooted() parameter "p" cannot be empty'); if (!p) {
} throw new Error('isRooted() parameter "p" cannot be empty');
if (exports.IS_WINDOWS) { }
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello if (exports.IS_WINDOWS) {
); // e.g. C: or C:\hello return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
} ); // e.g. C: or C:\hello
return p.startsWith('/'); }
} return p.startsWith('/');
exports.isRooted = isRooted; }
/** exports.isRooted = isRooted;
* Recursively create a directory at `fsPath`. /**
* * Recursively create a directory at `fsPath`.
* This implementation is optimistic, meaning it attempts to create the full *
* path first, and backs up the path stack from there. * This implementation is optimistic, meaning it attempts to create the full
* * path first, and backs up the path stack from there.
* @param fsPath The path to create *
* @param maxDepth The maximum recursion depth * @param fsPath The path to create
* @param depth The current recursion depth * @param maxDepth The maximum recursion depth
*/ * @param depth The current recursion depth
function mkdirP(fsPath, maxDepth = 1000, depth = 1) { */
return __awaiter(this, void 0, void 0, function* () { function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
assert_1.ok(fsPath, 'a path argument must be provided'); return __awaiter(this, void 0, void 0, function* () {
fsPath = path.resolve(fsPath); assert_1.ok(fsPath, 'a path argument must be provided');
if (depth >= maxDepth) fsPath = path.resolve(fsPath);
return exports.mkdir(fsPath); if (depth >= maxDepth)
try { return exports.mkdir(fsPath);
yield exports.mkdir(fsPath); try {
return; yield exports.mkdir(fsPath);
} return;
catch (err) { }
switch (err.code) { catch (err) {
case 'ENOENT': { switch (err.code) {
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); case 'ENOENT': {
yield exports.mkdir(fsPath); yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
return; yield exports.mkdir(fsPath);
} return;
default: { }
let stats; default: {
try { let stats;
stats = yield exports.stat(fsPath); try {
} stats = yield exports.stat(fsPath);
catch (err2) { }
throw err; catch (err2) {
} throw err;
if (!stats.isDirectory()) }
throw err; if (!stats.isDirectory())
} throw err;
} }
} }
}); }
} });
exports.mkdirP = mkdirP; }
/** exports.mkdirP = mkdirP;
* Best effort attempt to determine whether a file exists and is executable. /**
* @param filePath file path to check * Best effort attempt to determine whether a file exists and is executable.
* @param extensions additional file extensions to try * @param filePath file path to check
* @return if file exists and is executable, returns the file path. otherwise empty string. * @param extensions additional file extensions to try
*/ * @return if file exists and is executable, returns the file path. otherwise empty string.
function tryGetExecutablePath(filePath, extensions) { */
return __awaiter(this, void 0, void 0, function* () { function tryGetExecutablePath(filePath, extensions) {
let stats = undefined; return __awaiter(this, void 0, void 0, function* () {
try { let stats = undefined;
// test file exists try {
stats = yield exports.stat(filePath); // test file exists
} stats = yield exports.stat(filePath);
catch (err) { }
if (err.code !== 'ENOENT') { catch (err) {
// eslint-disable-next-line no-console if (err.code !== 'ENOENT') {
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); // eslint-disable-next-line no-console
} console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
} }
if (stats && stats.isFile()) { }
if (exports.IS_WINDOWS) { if (stats && stats.isFile()) {
// on Windows, test for valid extension if (exports.IS_WINDOWS) {
const upperExt = path.extname(filePath).toUpperCase(); // on Windows, test for valid extension
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { const upperExt = path.extname(filePath).toUpperCase();
return filePath; if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
} return filePath;
} }
else { }
if (isUnixExecutable(stats)) { else {
return filePath; if (isUnixExecutable(stats)) {
} return filePath;
} }
} }
// try each extension }
const originalFilePath = filePath; // try each extension
for (const extension of extensions) { const originalFilePath = filePath;
filePath = originalFilePath + extension; for (const extension of extensions) {
stats = undefined; filePath = originalFilePath + extension;
try { stats = undefined;
stats = yield exports.stat(filePath); try {
} stats = yield exports.stat(filePath);
catch (err) { }
if (err.code !== 'ENOENT') { catch (err) {
// eslint-disable-next-line no-console if (err.code !== 'ENOENT') {
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); // eslint-disable-next-line no-console
} console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
} }
if (stats && stats.isFile()) { }
if (exports.IS_WINDOWS) { if (stats && stats.isFile()) {
// preserve the case of the actual file (since an extension was appended) if (exports.IS_WINDOWS) {
try { // preserve the case of the actual file (since an extension was appended)
const directory = path.dirname(filePath); try {
const upperName = path.basename(filePath).toUpperCase(); const directory = path.dirname(filePath);
for (const actualName of yield exports.readdir(directory)) { const upperName = path.basename(filePath).toUpperCase();
if (upperName === actualName.toUpperCase()) { for (const actualName of yield exports.readdir(directory)) {
filePath = path.join(directory, actualName); if (upperName === actualName.toUpperCase()) {
break; filePath = path.join(directory, actualName);
} break;
} }
} }
catch (err) { }
// eslint-disable-next-line no-console catch (err) {
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); // eslint-disable-next-line no-console
} console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
return filePath; }
} return filePath;
else { }
if (isUnixExecutable(stats)) { else {
return filePath; if (isUnixExecutable(stats)) {
} return filePath;
} }
} }
} }
return ''; }
}); return '';
} });
exports.tryGetExecutablePath = tryGetExecutablePath; }
function normalizeSeparators(p) { exports.tryGetExecutablePath = tryGetExecutablePath;
p = p || ''; function normalizeSeparators(p) {
if (exports.IS_WINDOWS) { p = p || '';
// convert slashes on Windows if (exports.IS_WINDOWS) {
p = p.replace(/\//g, '\\'); // convert slashes on Windows
// remove redundant slashes p = p.replace(/\//g, '\\');
return p.replace(/\\\\+/g, '\\'); // remove redundant slashes
} return p.replace(/\\\\+/g, '\\');
// remove redundant slashes }
return p.replace(/\/\/+/g, '/'); // remove redundant slashes
} return p.replace(/\/\/+/g, '/');
// on Mac/Linux, test the execute bit }
// R W X R W X R W X // on Mac/Linux, test the execute bit
// 256 128 64 32 16 8 4 2 1 // R W X R W X R W X
function isUnixExecutable(stats) { // 256 128 64 32 16 8 4 2 1
return ((stats.mode & 1) > 0 || function isUnixExecutable(stats) {
((stats.mode & 8) > 0 && stats.gid === process.getgid()) || return ((stats.mode & 1) > 0 ||
((stats.mode & 64) > 0 && stats.uid === process.getuid())); ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
} ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
}
//# sourceMappingURL=io-util.js.map //# sourceMappingURL=io-util.js.map

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"}

112
node_modules/@actions/io/lib/io.d.ts generated vendored
View File

@@ -1,56 +1,56 @@
/** /**
* Interface for cp/mv options * Interface for cp/mv options
*/ */
export interface CopyOptions { export interface CopyOptions {
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */ /** Optional. Whether to recursively copy all subdirectories. Defaults to false */
recursive?: boolean; recursive?: boolean;
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */ /** Optional. Whether to overwrite existing files in the destination. Defaults to true */
force?: boolean; force?: boolean;
} }
/** /**
* Interface for cp/mv options * Interface for cp/mv options
*/ */
export interface MoveOptions { export interface MoveOptions {
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */ /** Optional. Whether to overwrite existing files in the destination. Defaults to true */
force?: boolean; force?: boolean;
} }
/** /**
* Copies a file or folder. * Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See CopyOptions. * @param options optional. See CopyOptions.
*/ */
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>; export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
/** /**
* Moves a path. * Moves a path.
* *
* @param source source path * @param source source path
* @param dest destination path * @param dest destination path
* @param options optional. See MoveOptions. * @param options optional. See MoveOptions.
*/ */
export declare function mv(source: string, dest: string, options?: MoveOptions): Promise<void>; export declare function mv(source: string, dest: string, options?: MoveOptions): Promise<void>;
/** /**
* Remove a path recursively with force * Remove a path recursively with force
* *
* @param inputPath path to remove * @param inputPath path to remove
*/ */
export declare function rmRF(inputPath: string): Promise<void>; export declare function rmRF(inputPath: string): Promise<void>;
/** /**
* Make a directory. Creates the full path with folders in between * Make a directory. Creates the full path with folders in between
* Will throw if it fails * Will throw if it fails
* *
* @param fsPath path to create * @param fsPath path to create
* @returns Promise<void> * @returns Promise<void>
*/ */
export declare function mkdirP(fsPath: string): Promise<void>; export declare function mkdirP(fsPath: string): Promise<void>;
/** /**
* Returns path of a tool had the tool actually been invoked. Resolves via paths. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw. * If you check and the tool does not exist, it will throw.
* *
* @param tool name of the tool * @param tool name of the tool
* @param check whether to check if tool exists * @param check whether to check if tool exists
* @returns Promise<string> path to tool * @returns Promise<string> path to tool
*/ */
export declare function which(tool: string, check?: boolean): Promise<string>; export declare function which(tool: string, check?: boolean): Promise<string>;

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

@@ -1,289 +1,290 @@
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } return new (P || (P = Promise))(function (resolve, reject) {
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
step((generator = generator.apply(thisArg, _arguments || [])).next()); 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 }); };
const childProcess = require("child_process"); Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path"); const childProcess = require("child_process");
const util_1 = require("util"); const path = require("path");
const ioUtil = require("./io-util"); const util_1 = require("util");
const exec = util_1.promisify(childProcess.exec); const ioUtil = require("./io-util");
/** const exec = util_1.promisify(childProcess.exec);
* Copies a file or folder. /**
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js * Copies a file or folder.
* * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
* @param source source path *
* @param dest destination path * @param source source path
* @param options optional. See CopyOptions. * @param dest destination path
*/ * @param options optional. See CopyOptions.
function cp(source, dest, options = {}) { */
return __awaiter(this, void 0, void 0, function* () { function cp(source, dest, options = {}) {
const { force, recursive } = readCopyOptions(options); return __awaiter(this, void 0, void 0, function* () {
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; const { force, recursive } = readCopyOptions(options);
// Dest is an existing file, but not forcing const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
if (destStat && destStat.isFile() && !force) { // Dest is an existing file, but not forcing
return; if (destStat && destStat.isFile() && !force) {
} return;
// If dest is an existing directory, should copy inside. }
const newDest = destStat && destStat.isDirectory() // If dest is an existing directory, should copy inside.
? path.join(dest, path.basename(source)) const newDest = destStat && destStat.isDirectory()
: dest; ? path.join(dest, path.basename(source))
if (!(yield ioUtil.exists(source))) { : dest;
throw new Error(`no such file or directory: ${source}`); if (!(yield ioUtil.exists(source))) {
} throw new Error(`no such file or directory: ${source}`);
const sourceStat = yield ioUtil.stat(source); }
if (sourceStat.isDirectory()) { const sourceStat = yield ioUtil.stat(source);
if (!recursive) { if (sourceStat.isDirectory()) {
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); if (!recursive) {
} throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
else { }
yield cpDirRecursive(source, newDest, 0, force); else {
} yield cpDirRecursive(source, newDest, 0, force);
} }
else { }
if (path.relative(source, newDest) === '') { else {
// a file cannot be copied to itself if (path.relative(source, newDest) === '') {
throw new Error(`'${newDest}' and '${source}' are the same file`); // a file cannot be copied to itself
} throw new Error(`'${newDest}' and '${source}' are the same file`);
yield copyFile(source, newDest, force); }
} yield copyFile(source, newDest, force);
}); }
} });
exports.cp = cp; }
/** exports.cp = cp;
* Moves a path. /**
* * Moves a path.
* @param source source path *
* @param dest destination path * @param source source path
* @param options optional. See MoveOptions. * @param dest destination path
*/ * @param options optional. See MoveOptions.
function mv(source, dest, options = {}) { */
return __awaiter(this, void 0, void 0, function* () { function mv(source, dest, options = {}) {
if (yield ioUtil.exists(dest)) { return __awaiter(this, void 0, void 0, function* () {
let destExists = true; if (yield ioUtil.exists(dest)) {
if (yield ioUtil.isDirectory(dest)) { let destExists = true;
// If dest is directory copy src into dest if (yield ioUtil.isDirectory(dest)) {
dest = path.join(dest, path.basename(source)); // If dest is directory copy src into dest
destExists = yield ioUtil.exists(dest); dest = path.join(dest, path.basename(source));
} destExists = yield ioUtil.exists(dest);
if (destExists) { }
if (options.force == null || options.force) { if (destExists) {
yield rmRF(dest); if (options.force == null || options.force) {
} yield rmRF(dest);
else { }
throw new Error('Destination already exists'); else {
} throw new Error('Destination already exists');
} }
} }
yield mkdirP(path.dirname(dest)); }
yield ioUtil.rename(source, dest); yield mkdirP(path.dirname(dest));
}); yield ioUtil.rename(source, dest);
} });
exports.mv = mv; }
/** exports.mv = mv;
* Remove a path recursively with force /**
* * Remove a path recursively with force
* @param inputPath path to remove *
*/ * @param inputPath path to remove
function rmRF(inputPath) { */
return __awaiter(this, void 0, void 0, function* () { function rmRF(inputPath) {
if (ioUtil.IS_WINDOWS) { return __awaiter(this, void 0, void 0, function* () {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another if (ioUtil.IS_WINDOWS) {
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
try { // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
if (yield ioUtil.isDirectory(inputPath, true)) { try {
yield exec(`rd /s /q "${inputPath}"`); if (yield ioUtil.isDirectory(inputPath, true)) {
} yield exec(`rd /s /q "${inputPath}"`);
else { }
yield exec(`del /f /a "${inputPath}"`); else {
} yield exec(`del /f /a "${inputPath}"`);
} }
catch (err) { }
// if you try to delete a file that doesn't exist, desired result is achieved catch (err) {
// other errors are valid // if you try to delete a file that doesn't exist, desired result is achieved
if (err.code !== 'ENOENT') // other errors are valid
throw err; if (err.code !== 'ENOENT')
} throw err;
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that }
try { // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
yield ioUtil.unlink(inputPath); try {
} yield ioUtil.unlink(inputPath);
catch (err) { }
// if you try to delete a file that doesn't exist, desired result is achieved catch (err) {
// other errors are valid // if you try to delete a file that doesn't exist, desired result is achieved
if (err.code !== 'ENOENT') // other errors are valid
throw err; if (err.code !== 'ENOENT')
} throw err;
} }
else { }
let isDir = false; else {
try { let isDir = false;
isDir = yield ioUtil.isDirectory(inputPath); try {
} isDir = yield ioUtil.isDirectory(inputPath);
catch (err) { }
// if you try to delete a file that doesn't exist, desired result is achieved catch (err) {
// other errors are valid // if you try to delete a file that doesn't exist, desired result is achieved
if (err.code !== 'ENOENT') // other errors are valid
throw err; if (err.code !== 'ENOENT')
return; throw err;
} return;
if (isDir) { }
yield exec(`rm -rf "${inputPath}"`); if (isDir) {
} yield exec(`rm -rf "${inputPath}"`);
else { }
yield ioUtil.unlink(inputPath); else {
} yield ioUtil.unlink(inputPath);
} }
}); }
} });
exports.rmRF = rmRF; }
/** exports.rmRF = rmRF;
* Make a directory. Creates the full path with folders in between /**
* Will throw if it fails * Make a directory. Creates the full path with folders in between
* * Will throw if it fails
* @param fsPath path to create *
* @returns Promise<void> * @param fsPath path to create
*/ * @returns Promise<void>
function mkdirP(fsPath) { */
return __awaiter(this, void 0, void 0, function* () { function mkdirP(fsPath) {
yield ioUtil.mkdirP(fsPath); return __awaiter(this, void 0, void 0, function* () {
}); yield ioUtil.mkdirP(fsPath);
} });
exports.mkdirP = mkdirP; }
/** exports.mkdirP = mkdirP;
* Returns path of a tool had the tool actually been invoked. Resolves via paths. /**
* If you check and the tool does not exist, it will throw. * Returns path of a tool had the tool actually been invoked. Resolves via paths.
* * If you check and the tool does not exist, it will throw.
* @param tool name of the tool *
* @param check whether to check if tool exists * @param tool name of the tool
* @returns Promise<string> path to tool * @param check whether to check if tool exists
*/ * @returns Promise<string> path to tool
function which(tool, check) { */
return __awaiter(this, void 0, void 0, function* () { function which(tool, check) {
if (!tool) { return __awaiter(this, void 0, void 0, function* () {
throw new Error("parameter 'tool' is required"); if (!tool) {
} throw new Error("parameter 'tool' is required");
// recursive when check=true }
if (check) { // recursive when check=true
const result = yield which(tool, false); if (check) {
if (!result) { const result = yield which(tool, false);
if (ioUtil.IS_WINDOWS) { if (!result) {
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); if (ioUtil.IS_WINDOWS) {
} throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
else { }
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); else {
} throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
} }
} }
try { }
// build the list of extensions to try try {
const extensions = []; // build the list of extensions to try
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { const extensions = [];
for (const extension of process.env.PATHEXT.split(path.delimiter)) { if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
if (extension) { for (const extension of process.env.PATHEXT.split(path.delimiter)) {
extensions.push(extension); if (extension) {
} extensions.push(extension);
} }
} }
// if it's rooted, return it if exists. otherwise return empty. }
if (ioUtil.isRooted(tool)) { // if it's rooted, return it if exists. otherwise return empty.
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); if (ioUtil.isRooted(tool)) {
if (filePath) { const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
return filePath; if (filePath) {
} return filePath;
return ''; }
} return '';
// if any path separators, return empty }
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { // if any path separators, return empty
return ''; if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
} return '';
// build the list of directories }
// // build the list of directories
// Note, technically "where" checks the current directory on Windows. From a task lib perspective, //
// it feels like we should not do this. Checking the current directory seems like more of a use // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
// case of a shell, and the which() function exposed by the task lib should strive for consistency // it feels like we should not do this. Checking the current directory seems like more of a use
// across platforms. // case of a shell, and the which() function exposed by the toolkit should strive for consistency
const directories = []; // across platforms.
if (process.env.PATH) { const directories = [];
for (const p of process.env.PATH.split(path.delimiter)) { if (process.env.PATH) {
if (p) { for (const p of process.env.PATH.split(path.delimiter)) {
directories.push(p); if (p) {
} directories.push(p);
} }
} }
// return the first match }
for (const directory of directories) { // return the first match
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); for (const directory of directories) {
if (filePath) { const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
return filePath; if (filePath) {
} return filePath;
} }
return ''; }
} return '';
catch (err) { }
throw new Error(`which failed with message ${err.message}`); catch (err) {
} throw new Error(`which failed with message ${err.message}`);
}); }
} });
exports.which = which; }
function readCopyOptions(options) { exports.which = which;
const force = options.force == null ? true : options.force; function readCopyOptions(options) {
const recursive = Boolean(options.recursive); const force = options.force == null ? true : options.force;
return { force, recursive }; const recursive = Boolean(options.recursive);
} return { force, recursive };
function cpDirRecursive(sourceDir, destDir, currentDepth, force) { }
return __awaiter(this, void 0, void 0, function* () { function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
// Ensure there is not a run away recursive copy return __awaiter(this, void 0, void 0, function* () {
if (currentDepth >= 255) // Ensure there is not a run away recursive copy
return; if (currentDepth >= 255)
currentDepth++; return;
yield mkdirP(destDir); currentDepth++;
const files = yield ioUtil.readdir(sourceDir); yield mkdirP(destDir);
for (const fileName of files) { const files = yield ioUtil.readdir(sourceDir);
const srcFile = `${sourceDir}/${fileName}`; for (const fileName of files) {
const destFile = `${destDir}/${fileName}`; const srcFile = `${sourceDir}/${fileName}`;
const srcFileStat = yield ioUtil.lstat(srcFile); const destFile = `${destDir}/${fileName}`;
if (srcFileStat.isDirectory()) { const srcFileStat = yield ioUtil.lstat(srcFile);
// Recurse if (srcFileStat.isDirectory()) {
yield cpDirRecursive(srcFile, destFile, currentDepth, force); // Recurse
} yield cpDirRecursive(srcFile, destFile, currentDepth, force);
else { }
yield copyFile(srcFile, destFile, force); else {
} yield copyFile(srcFile, destFile, force);
} }
// Change the mode for the newly created directory }
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); // Change the mode for the newly created directory
}); yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
} });
// Buffered file copy }
function copyFile(srcFile, destFile, force) { // Buffered file copy
return __awaiter(this, void 0, void 0, function* () { function copyFile(srcFile, destFile, force) {
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) { return __awaiter(this, void 0, void 0, function* () {
// unlink/re-link it if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
try { // unlink/re-link it
yield ioUtil.lstat(destFile); try {
yield ioUtil.unlink(destFile); yield ioUtil.lstat(destFile);
} yield ioUtil.unlink(destFile);
catch (e) { }
// Try to override file permission catch (e) {
if (e.code === 'EPERM') { // Try to override file permission
yield ioUtil.chmod(destFile, '0666'); if (e.code === 'EPERM') {
yield ioUtil.unlink(destFile); yield ioUtil.chmod(destFile, '0666');
} yield ioUtil.unlink(destFile);
// other errors = it doesn't exist, no work to do }
} // other errors = it doesn't exist, no work to do
// Copy over symlink }
const symlinkFull = yield ioUtil.readlink(srcFile); // Copy over symlink
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null); const symlinkFull = yield ioUtil.readlink(srcFile);
} yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
else if (!(yield ioUtil.exists(destFile)) || force) { }
yield ioUtil.copyFile(srcFile, destFile); else if (!(yield ioUtil.exists(destFile)) || force) {
} yield ioUtil.copyFile(srcFile, destFile);
}); }
} });
}
//# sourceMappingURL=io.js.map //# sourceMappingURL=io.js.map

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];
@@ -208,4 +206,34 @@ 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;
} }
@@ -289,4 +284,9 @@ function MetaProperty(node) {
function PrivateName(node) { 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) {
@@ -712,4 +728,31 @@ 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);
}; };
} }
@@ -408,7 +405,7 @@ helpers.objectSpread2 = helper("7.5.0")`
import defineProperty from "defineProperty"; import defineProperty from "defineProperty";
// This function is different to "Reflect.ownKeys". The enumerableOnly // This function is different to "Reflect.ownKeys". The enumerableOnly
// filters on symbol properties only. Returned string properties are always // filters on symbol properties only. Returned string properties are always
// enumerable. It is good to use in objectSpread. // enumerable. It is good to use in objectSpread.
function ownKeys(object, enumerableOnly) { function ownKeys(object, enumerableOnly) {
@@ -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) {

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