Use NPM instead of yarn
This commit is contained in:
parent
f87cce811b
commit
5d84f19c10
|
@ -2,18 +2,17 @@
|
||||||
"name": "@pulumi/mypkg",
|
"name": "@pulumi/mypkg",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc"
|
"build": "tsc",
|
||||||
|
"test": "mocha -r ts-node/register tests/**/*.spec.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@pulumi/pulumi": "file:../../../../../../../sdk/nodejs/bin",
|
||||||
"@types/mocha": "latest",
|
"@types/mocha": "latest",
|
||||||
"@types/node": "latest",
|
"@types/node": "latest",
|
||||||
"mocha": "latest",
|
"mocha": "latest",
|
||||||
"ts-node": "latest",
|
"ts-node": "latest",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
|
||||||
"@pulumi/pulumi": "latest"
|
|
||||||
},
|
|
||||||
"pulumi": {
|
"pulumi": {
|
||||||
"resource": true
|
"resource": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,11 +577,15 @@
|
||||||
"@types/mocha": "latest",
|
"@types/mocha": "latest",
|
||||||
"@types/node": "latest",
|
"@types/node": "latest",
|
||||||
"mocha": "latest",
|
"mocha": "latest",
|
||||||
"ts-node": "latest"
|
"ts-node": "latest",
|
||||||
|
"@pulumi/pulumi": "file:../../../../../../../sdk/nodejs/bin"
|
||||||
},
|
},
|
||||||
"extraTypeScriptFiles": [
|
"extraTypeScriptFiles": [
|
||||||
"tests/codegen.spec.ts"
|
"tests/codegen.spec.ts"
|
||||||
]
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha -r ts-node/register tests/**/*.spec.ts"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1845,22 +1845,30 @@ func genNPMPackageMetadata(pkg *schema.Package, info NodePackageInfo) string {
|
||||||
packageVersion = pkg.Version.String()
|
packageVersion = pkg.Version.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ideally, this `scripts` section would include an install
|
||||||
|
// script that installs the provider, however, doing so causes
|
||||||
|
// problems when we try to restore package dependencies, since
|
||||||
|
// we must do an install for that. So we have another process
|
||||||
|
// that adds the install script when generating the
|
||||||
|
// package.json that we actually publish.
|
||||||
|
scripts := map[string]string{
|
||||||
|
"build": "tsc",
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range info.Scripts {
|
||||||
|
scripts[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
// Create info that will get serialized into an NPM package.json.
|
// Create info that will get serialized into an NPM package.json.
|
||||||
npminfo := npmPackage{
|
npminfo := npmPackage{
|
||||||
Name: packageName,
|
Name: packageName,
|
||||||
Version: packageVersion,
|
Version: packageVersion,
|
||||||
Description: info.PackageDescription,
|
Description: info.PackageDescription,
|
||||||
Keywords: pkg.Keywords,
|
Keywords: pkg.Keywords,
|
||||||
Homepage: pkg.Homepage,
|
Homepage: pkg.Homepage,
|
||||||
Repository: pkg.Repository,
|
Repository: pkg.Repository,
|
||||||
License: pkg.License,
|
License: pkg.License,
|
||||||
// Ideally, this `scripts` section would include an install script that installs the provider, however, doing
|
Scripts: scripts,
|
||||||
// so causes problems when we try to restore package dependencies, since we must do an install for that. So
|
|
||||||
// we have another process that adds the install script when generating the package.json that we actually
|
|
||||||
// publish.
|
|
||||||
Scripts: map[string]string{
|
|
||||||
"build": "tsc",
|
|
||||||
},
|
|
||||||
DevDependencies: devDependencies,
|
DevDependencies: devDependencies,
|
||||||
Pulumi: npmPulumiManifest{
|
Pulumi: npmPulumiManifest{
|
||||||
Resource: true,
|
Resource: true,
|
||||||
|
|
|
@ -22,33 +22,12 @@ func TestGeneratePackage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func typeCheckGeneratedPackage(t *testing.T, pwd string) {
|
func typeCheckGeneratedPackage(t *testing.T, pwd string) {
|
||||||
// TODO: previous attempt used npm. It may be more popular and
|
test.RunCommand(t, "npm_install", pwd, "npm", "install")
|
||||||
// better target than yarn, however our build uses yarn in
|
test.RunCommand(t, "npm_build", pwd, "npm", "run", "build")
|
||||||
// other places at the moment, and yarn does not run into the
|
|
||||||
// ${VERSION} problem; use yarn for now.
|
|
||||||
//
|
|
||||||
// var npm string
|
|
||||||
// npm, err = executable.FindExecutable("npm")
|
|
||||||
// require.NoError(t, err)
|
|
||||||
// // TODO remove when https://github.com/pulumi/pulumi/pull/7938 lands
|
|
||||||
// file := filepath.Join(pwd, "package.json")
|
|
||||||
// oldFile, err := ioutil.ReadFile(file)
|
|
||||||
// require.NoError(t, err)
|
|
||||||
// newFile := strings.ReplaceAll(string(oldFile), "${VERSION}", "0.0.1")
|
|
||||||
// err = ioutil.WriteFile(file, []byte(newFile), 0600)
|
|
||||||
// require.NoError(t, err)
|
|
||||||
// err = integration.RunCommand(t, "npm install", []string{npm, "i"}, pwd, &cmdOptions)
|
|
||||||
// require.NoError(t, err)
|
|
||||||
|
|
||||||
test.RunCommand(t, "yarn_link", pwd, "yarn", "link", "@pulumi/pulumi")
|
|
||||||
test.RunCommand(t, "yarn_install", pwd, "yarn", "install")
|
|
||||||
test.RunCommand(t, "tsc", pwd, "yarn", "run", "tsc", "--noEmit")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs unit tests against the generated code.
|
|
||||||
func testGeneratedPackage(t *testing.T, pwd string) {
|
func testGeneratedPackage(t *testing.T, pwd string) {
|
||||||
test.RunCommand(t, "mocha", pwd,
|
test.RunCommand(t, "npm_test", pwd, "npm", "run", "test")
|
||||||
"yarn", "run", "mocha", "-r", "ts-node/register", "tests/**/*.spec.ts")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateTypeNames(t *testing.T) {
|
func TestGenerateTypeNames(t *testing.T) {
|
||||||
|
|
|
@ -64,6 +64,10 @@ type NodePackageInfo struct {
|
||||||
// compiling hand-authored unit test files that check the
|
// compiling hand-authored unit test files that check the
|
||||||
// generated code.
|
// generated code.
|
||||||
ExtraTypeScriptFiles []string `json:"extraTypeScriptFiles,omitempty"`
|
ExtraTypeScriptFiles []string `json:"extraTypeScriptFiles,omitempty"`
|
||||||
|
// NPM script definitions. These define the `scripts` property
|
||||||
|
// of the generated `package.json`. See also:
|
||||||
|
// https://docs.npmjs.com/cli/v7/using-npm/scripts
|
||||||
|
Scripts map[string]string `json:"scripts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeObjectInfo contains NodeJS-specific information for an object.
|
// NodeObjectInfo contains NodeJS-specific information for an object.
|
||||||
|
|
Loading…
Reference in a new issue