Add deprecation warnings. (#3004)

This commit is contained in:
CyrusNajmabadi 2019-07-30 15:51:44 -07:00 committed by GitHub
parent 852a8f9dc9
commit 7bdd590586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 25 deletions

View file

@ -3,6 +3,14 @@ CHANGELOG
## Unreleased
### Compatibility
* Deprecated functions in `@pulumi/pulumi` will now issue warnings if you call them. Please migrate
off of these functions as they will be removed in a future release. The deprecated functions are.
1. `function computeCodePaths(extraIncludePaths?: string[], ...)`. Use the `computeCodePaths`
overload that takes a `CodePathOptions` instead.
2. `function serializeFunctionAsync`. Please use `serializeFunction` instead.
## 0.17.27 (2019-07-29)
- Fix an error message from the logging subsystem which was introduced in v0.17.26

View file

@ -18,6 +18,7 @@ import * as fs from "fs";
import * as normalize from "normalize-package-data";
import * as readPackageTree from "read-package-tree";
import * as upath from "upath";
import { log } from "../..";
import * as asset from "../../asset";
import { ResourceError } from "../../errors";
import { Resource } from "../../resource";
@ -54,25 +55,26 @@ export interface CodePathOptions {
logResource?: Resource;
}
// computeCodePaths computes the local node_module paths to include in an uploaded cloud 'Lambda'.
// Specifically, it will examine the package.json for the caller's code, and will transitively walk
// it's 'dependencies' section to determine what packages should be included.
//
// During this walk, if a package is encountered that contains a `"pulumi": { ... }` section then
// the normal `"dependencies": { ... }` section of that package will not be included. These are
// "pulumi" packages, and those dependencies are only intended for use at deployment time. However,
// a "pulumi" package can also specify package that should be available at cloud-runtime. These
// packages are found in a `"runtimeDependencies": { ... }` section in the package.json file with
// the same format as the normal "dependencies" section.
//
// See [CodePathOptions] for information on ways to control and configure the final set of paths
// included in the resultant asset/archive map.
//
// Note: this functionality is specifically intended for use by downstream library code that is
// determining what is needed for a cloud-lambda. i.e. the aws.serverless.Function or
// azure.serverless.FunctionApp libraries. In general, other clients should not need to use this
// helper.
/**
* computeCodePaths computes the local node_module paths to include in an uploaded cloud 'Lambda'.
* Specifically, it will examine the package.json for the caller's code, and will transitively walk
* it's 'dependencies' section to determine what packages should be included.
*
* During this walk, if a package is encountered that contains a `"pulumi": { ... }` section then
* the normal `"dependencies": { ... }` section of that package will not be included. These are
* "pulumi" packages, and those dependencies are only intended for use at deployment time. However,
* a "pulumi" package can also specify package that should be available at cloud-runtime. These
* packages are found in a `"runtimeDependencies": { ... }` section in the package.json file with
* the same format as the normal "dependencies" section.
*
* See [CodePathOptions] for information on ways to control and configure the final set of paths
* included in the resultant asset/archive map.
*
* Note: this functionality is specifically intended for use by downstream library code that is
* determining what is needed for a cloud-lambda. i.e. the aws.serverless.Function or
* azure.serverless.FunctionApp libraries. In general, other clients should not need to use this
* helper.
*/
export async function computeCodePaths(options?: CodePathOptions): Promise<Map<string, asset.Asset | asset.Archive>>;
/**
@ -87,17 +89,15 @@ export async function computeCodePaths(
let options: CodePathOptions;
if (Array.isArray(optionsOrExtraIncludePaths)) {
log.warn("'function computeCodePaths(string[])' is deprecated. Use the [computeCodePaths] overload that takes a [CodePathOptions] instead.");
options = {
extraIncludePaths: optionsOrExtraIncludePaths,
extraIncludePackages,
extraExcludePackages,
};
}
else if (optionsOrExtraIncludePaths) {
options = optionsOrExtraIncludePaths;
}
else {
options = {};
options = optionsOrExtraIncludePaths || {};
}
return computeCodePathsWorker(options);

View file

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { log } from "../..";
import { Resource } from "../../resource";
import * as closure from "./createClosure";
import * as utils from "./utils";
@ -94,12 +95,13 @@ export async function serializeFunction(
}
/**
* @deprecated This function has been replaced by `serializeFunction`, which accepts additional parameters and returns
* more details about the serialized function. This form will be removed in a future release of this package.
* @deprecated Please use 'serializeFunction' instead.
*/
export async function serializeFunctionAsync(
func: Function,
serialize?: (o: any) => boolean): Promise<string> {
log.warn("'function serializeFunctionAsync' is deprecated. Please use 'serializeFunction' instead.");
serialize = serialize || (_ => true);
const functionInfo = await closure.createFunctionInfoAsync(func, serialize, /*logResource:*/ undefined);
return serializeJavaScriptText(functionInfo, "handler", /*isFactoryFunction*/ false).text;