Code Monkey home page Code Monkey logo

nodejs-storage's Introduction

Google Cloud Platform logo

release level npm version

Node.js idiomatic client for Cloud Storage.

Cloud Storage allows world-wide storage and retrieval of any amount of data at any time. You can use Google Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Google Cloud Storage API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/storage

Using the client library

// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');

// For more information on ways to initialize Storage, please see
// https://googleapis.dev/nodejs/storage/latest/Storage.html

// Creates a client using Application Default Credentials
const storage = new Storage();

// Creates a client from a Google service account key
// const storage = new Storage({keyFilename: 'key.json'});

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// The ID of your GCS bucket
// const bucketName = 'your-unique-bucket-name';

async function createBucket() {
  // Creates the new bucket
  await storage.createBucket(bucketName);
  console.log(`Bucket ${bucketName} created.`);
}

createBucket().catch(console.error);

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
Add Bucket Conditional Binding source code Open in Cloud Shell
Add Bucket Default Owner Acl source code Open in Cloud Shell
Add Bucket Iam Member source code Open in Cloud Shell
Storage Add Bucket Label. source code Open in Cloud Shell
Add Bucket Owner Acl source code Open in Cloud Shell
Bucket Website Configuration. source code Open in Cloud Shell
Add File Owner Acl source code Open in Cloud Shell
Storage Get Bucket Metadata. source code Open in Cloud Shell
Change Bucket's Default Storage Class. source code Open in Cloud Shell
Storage File Convert CSEK to CMEK. source code Open in Cloud Shell
Storage Combine files. source code Open in Cloud Shell
Storage Configure Bucket Cors. source code Open in Cloud Shell
Configure Retries source code Open in Cloud Shell
Copy File source code Open in Cloud Shell
Copy Old Version Of File. source code Open in Cloud Shell
Create a Dual-Region Bucket source code Open in Cloud Shell
Create a Bucket with object retention enabled. source code Open in Cloud Shell
Create Bucket With Storage Class and Location. source code Open in Cloud Shell
Create Bucket With Turbo Replication source code Open in Cloud Shell
Create New Bucket source code Open in Cloud Shell
Create Notification source code Open in Cloud Shell
Delete Bucket source code Open in Cloud Shell
Delete File source code Open in Cloud Shell
Delete Notification source code Open in Cloud Shell
Delete Old Version Of File. source code Open in Cloud Shell
Disable Bucket Lifecycle Management source code Open in Cloud Shell
Storage Disable Bucket Versioning. source code Open in Cloud Shell
Disable Default Event Based Hold source code Open in Cloud Shell
Disable Requester Pays source code Open in Cloud Shell
Disable Uniform Bucket Level Access source code Open in Cloud Shell
Download Byte Range source code Open in Cloud Shell
Download Encrypted File source code Open in Cloud Shell
Download File source code Open in Cloud Shell
Download a File in Chunks With Transfer Manager source code Open in Cloud Shell
Download File Using Requester Pays source code Open in Cloud Shell
Download Folder With Transfer Manager source code Open in Cloud Shell
Download Into Memory source code Open in Cloud Shell
Download Many Files With Transfer Manager source code Open in Cloud Shell
Storage Download Public File. source code Open in Cloud Shell
Enable Bucket Lifecycle Management source code Open in Cloud Shell
Storage Enable Bucket Versioning. source code Open in Cloud Shell
Enable Default Event Based Hold source code Open in Cloud Shell
Enable Default KMS Key source code Open in Cloud Shell
Enable Requester Pays source code Open in Cloud Shell
Enable Uniform Bucket Level Access source code Open in Cloud Shell
Change File's Storage Class. source code Open in Cloud Shell
Storage Set File Metadata. source code Open in Cloud Shell
Generate Encryption Key source code Open in Cloud Shell
Generate Signed Url source code Open in Cloud Shell
Generate V4 Read Signed Url source code Open in Cloud Shell
Generate V4 Signed Policy source code Open in Cloud Shell
Generate V4 Upload Signed Url source code Open in Cloud Shell
Get Autoclass source code Open in Cloud Shell
Get Default Event Based Hold source code Open in Cloud Shell
Get Metadata source code Open in Cloud Shell
Get Metadata Notifications source code Open in Cloud Shell
Get Public Access Prevention source code Open in Cloud Shell
Get RPO source code Open in Cloud Shell
Get Requester Pays Status source code Open in Cloud Shell
Get Retention Policy source code Open in Cloud Shell
Storage Get Service Account. source code Open in Cloud Shell
Get Uniform Bucket Level Access source code Open in Cloud Shell
Activate HMAC SA Key. source code Open in Cloud Shell
Create HMAC SA Key. source code Open in Cloud Shell
Deactivate HMAC SA Key. source code Open in Cloud Shell
Delete HMAC SA Key. source code Open in Cloud Shell
Get HMAC SA Key Metadata. source code Open in Cloud Shell
List HMAC SA Keys Metadata. source code Open in Cloud Shell
List Buckets source code Open in Cloud Shell
List Files source code Open in Cloud Shell
List Files By Prefix source code Open in Cloud Shell
List Files Paginate source code Open in Cloud Shell
List Files with Old Versions. source code Open in Cloud Shell
List Notifications source code Open in Cloud Shell
Lock Retention Policy source code Open in Cloud Shell
Storage Make Bucket Public. source code Open in Cloud Shell
Make Public source code Open in Cloud Shell
Move File source code Open in Cloud Shell
Print Bucket Acl source code Open in Cloud Shell
Print Bucket Acl For User source code Open in Cloud Shell
Print File Acl source code Open in Cloud Shell
Print File Acl For User source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell
Release Event Based Hold source code Open in Cloud Shell
Release Temporary Hold source code Open in Cloud Shell
Remove Bucket Conditional Binding source code Open in Cloud Shell
Storage Remove Bucket Cors Configuration. source code Open in Cloud Shell
Remove Bucket Default Owner source code Open in Cloud Shell
Remove Bucket Iam Member source code Open in Cloud Shell
Storage Remove Bucket Label. source code Open in Cloud Shell
Remove Bucket Owner Acl source code Open in Cloud Shell
Remove Default KMS Key. source code Open in Cloud Shell
Remove File Owner Acl source code Open in Cloud Shell
Remove Retention Policy source code Open in Cloud Shell
Rename File source code Open in Cloud Shell
Rotate Encryption Key source code Open in Cloud Shell
Set Autoclass source code Open in Cloud Shell
Set Client Endpoint source code Open in Cloud Shell
Set Event Based Hold source code Open in Cloud Shell
Set the object retention policy of a File. source code Open in Cloud Shell
Set Public Access Prevention Enforced source code Open in Cloud Shell
Set Public Access Prevention Inherited source code Open in Cloud Shell
Set RPO Async Turbo source code Open in Cloud Shell
Set RPO Default source code Open in Cloud Shell
Set Retention Policy source code Open in Cloud Shell
Set Temporary Hold source code Open in Cloud Shell
Stream File Download source code Open in Cloud Shell
Stream File Upload source code Open in Cloud Shell
Upload a directory to a bucket. source code Open in Cloud Shell
Upload Directory With Transfer Manager source code Open in Cloud Shell
Upload Encrypted File source code Open in Cloud Shell
Upload File source code Open in Cloud Shell
Upload a File in Chunks With Transfer Manager source code Open in Cloud Shell
Upload File With Kms Key source code Open in Cloud Shell
Upload From Memory source code Open in Cloud Shell
Upload Many Files With Transfer Manager source code Open in Cloud Shell
Upload Without Authentication source code Open in Cloud Shell
Upload Without Authentication Signed Url source code Open in Cloud Shell
View Bucket Iam Members source code Open in Cloud Shell

The Google Cloud Storage Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/storage@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

nodejs-storage's People

Contributors

alexander-fenster avatar andrewsg avatar avaksman avatar bcoe avatar callmehiphop avatar danielbankhead avatar ddelgrosso1 avatar dpebot avatar fhinkel avatar frankyn avatar gcf-owl-bot[bot] avatar greenkeeper[bot] avatar jeanbza avatar jkwlui avatar jmdobry avatar jspri avatar justinbeckwith avatar laljikanjareeya avatar lukesneeringer avatar release-please[bot] avatar renovate-bot avatar renovate[bot] avatar rhodgkins avatar shaffeeullah avatar sofisl avatar stephenplusplus avatar summer-ji-eng avatar thomasdenh avatar yoshi-automation avatar zbjornson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-storage's Issues

Hide extraneous GCN plumbing from returned objects

From @adam-sandor on April 13, 2017 11:44

Fetching a list of files from my bucket produces 271K of JSON output from the server. And I just have 4 files in the bucket.
The data includes things like the complete description of the bucket itself (per every file) or the description of the googlecloud storage library (authors, dependencies, etc). Some of this is probably not loaded from the server but is added by the node api library. Even if that doesn't lead to network traffic it's still unnecessary and inconvenient when I try to find the relevant data. The screenshot below show the data structure with most elements collapsed. None of those elements are relevant for listing files in the bucket. I only want to see the data that is printed by gsutil when doing ls.

https://www.dropbox.com/s/4dgpu7jh8z6lb9h/Screen%20Shot%202017-04-13%20at%2013.29.58.png?dl=0

I might be missing some option or parameter that would limit the output from getFiles.

Environment details

  • OS: OSX
  • Node.js version: 7.2.0
  • npm version: 3.10.9
  • google-cloud-node version: 1.0.0

Steps to reproduce

var storage = require('@google-cloud/storage');
var fs = require('fs');

var gcs = storage({
    projectId: 'MYPROJECT'
});

var bucket = gcs.bucket('MYBUCKET');

bucket.getFiles(function(err, files) {
    if (!err) {
        fs.writeFileSync("files.json", JSON.stringify(files))
    } else {
        console.error(err)
    }
});

Copied from original issue: googleapis/google-cloud-node#2217

Save function doesn't exist

I am creating a firebase function where I need to call Google cloud storage library to store some contents using the save method: https://cloud.google.com/nodejs/docs/reference/storage/1.3.x/File#save

My code:

const Storage = require('@google-cloud/storage')({
    projectId: 'izotti-api',
    keyFilename: 'keyfile.json'
});
var myBucket = Storage.bucket('gs://izotti-api.appspot.com');

  const options = {
    action: 'read',
    expires: '12-31-2025'
  };

  //Front image storage task
  event.data.ref.parent.child('front_image').once('value').then((snapshot) => {
    const front_image = snapshot.val();
    console.log(front_image);

    //Store the file here by saving its content
    const file = myBucket.file(`${event.params.clientId}/front_image.png`);
    console.log(file);

    file.save(front_image, function(err) {
      if (!err) {
        console.log("Finished uploading front image");
      } else {
        console.log(err);
      }
    });

However, everytime at file.save it generates an error -

Error: Not Found
at Request._callback (/user_code/node_modules/@google-cloud/storage/node_modules/gcs-resumable-upload/index.js:283:25)
at Request.self.callback (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1163:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1085:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)

Why doesnt the save function work ? Or am I calling it incorrectly?

Environment details

  • OS: Darwin Kernel Version 15.4.0
  • Node.js version: v6.9.4
  • npm version: 3.10.10
  • @google-cloud/storage version: "^1.3.1"

Steps to reproduce

  1. New Instance of google cloud storage
  2. Create brand new content and save it using File.save as mentioned in https://cloud.google.com/nodejs/docs/reference/storage/1.3.x/File#save

Thanks!

Cloud Storage with local emulator

From @arbesfeld on October 20, 2016 19:50

There are a few "Mock s3" servers that run in memory/disk. Since the google cloud storage and S3 APIs are the same, I was wondering if there was a way to use one of these servers with the Cloud Storage client? If not, what is the recommended way to use this API for local development?

Copied from original issue: googleapis/google-cloud-node#1731

An in-range update of prettier is breaking the build 🚨

Version 1.9.0 of prettier was just published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.8.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node9 Your tests passed on CircleCI! Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

Release Notes 1.9.0: JSX Fragments, EditorConfig and Arrow Parens

image

This release adds an option for arrow function parens in arguments, support for the new JSX fragment syntax (<>), support for .editorconfig files, and nice additions to our GraphQL and Markdown support.

Highlights

JavaScript

Option to add parens in arrow function arguments (#3324) by @rattrayalex and @suchipi

When printing arrow functions, Prettier omitted parens around the arguments if they weren’t strictly necessary, like so:

// no parens
foo => {};

// parens
(foo: Number) => {};

// parens
({ foo }) => {}

// parens
(foo = 5) => {}

This lead to the most commented thread in our issue tracker. Prettier now has the --arrow-parens option (arrowParens in the config) that can assume two values today:

  • "avoid" - (default) preserve the behavior that omits parens when possible
  • "always" - always includes parens

JSX fragment syntax (#3237) by @duailibe

Prettier will now recognize and format JSX with the new fragment syntax, like the code below:

function MyComponent() {
  return (
    <>
      <Children1 />
      <Children2 />
      <Children3 />
    </>
  );
}

Fix slow formatting long texts in JSX (#3268, #3273) by @duailibe

We received feedback that formatting a JSX file with a really long text (~1000 lines) was really slow and noticed there was two performance bottlenecks in our fill primitive, which prints text until it reaches the print width and then insert a line break.

Markdown

Add an option to preserve text line breaks (#3340) by @ikatyang

After the release of our Markdown support, we received feedback that breaking text to respect the print width could affect some renderers that could be sensitive to line breaks. In 1.8.2 we released a new option proseWrap: false that would print a paragraph in a single line, and users would rely on the "soft wrapping" feature of editors.

In 1.9 we are releasing a new option proseWrap: "preserve" which will respect the original line breaks of text, and lets the users decide where the text should break.

[WARNING] proseWrap with boolean value is deprecated, use "always", "never" or "preserve" instead.

[BREAKING CHANGE] proseWrap option now defaults to "preserve" as some renderers are linebreak-sensitive.

GraphQL

Support top-level interpolations (#3370) by @lydell

When GraphQL support was released, Prettier did not support interpolation so it would skip formatting if any interpolations were present, because interpolations make formatting very difficult. While that works well for the most part, users of the Apollo Client were missing out on Prettier’s GraphQL support sometimes, because Apollo Client uses interpolation to share fragments between queries. The good news is that only top-level interpolations are allowed, and that was way easier to add support for in Prettier.

In 1.9 we format GraphQL queries with top-level interpolation:

gql`
  query User {
    user(id: "Bob") {
      ...UserDetails
    }
  }

  ${UserDetailsFragment}
`

(Prettier will continue to skip formatting if the interpolation is inside a query or mutation or so.)

Preserve intentional new lines in GraphQL (#3252) by @duailibe

Prettier will now respect intentional line breaks inside GraphQL queries (but limit to 1), where before it would remove them.

query User {
  name

age
}

CSS

Don't lowercase element names and attribute names in selectors (#3317) by @lydell

CSS is mostly case insensitive, so Prettier has been lowercasing stuff for a while to keep things consistent. Turns out we overlooked a detail in the CSS spec. Element and attribute names in selectors depend on the markup language: In HTML they are case insensitive, but in SVG (XML) they are not. Previously Prettier would incorrectly lowercase element and attribute names, but now we don’t anymore.

Configuration

Add EditorConfig support (#3255) by @josephfrazier

It's taken a while, but Prettier will finally respect your .editorconfig file. This includes:

  • indent_style
  • indent_size/tab_width
  • max_line_length

The prettier CLI respects .editorconfig by default, but you can opt out with --no-editorconfig.
However, the API doesn't respect .editorconfig by default, in order to avoid potential editor integration issues (see here for details). To opt in, add editorconfig: true to the prettier.resolveConfig options.

Other changes

JavaScript

Don't break simple elements in JSX (#3250) by @duailibe

Prettier won't break an element with no attributes anymore, keeping elements like <br /> as an unit.

Don't break identifiers inside template literals expressions (#3299) by @duailibe

In the previous release we tried a new strategy of breaking template literals with expressions inside to respect the print width. We've received feedback that for some cases it was actually preferred that it would exceed print width than breaking in multiple lines.

From now on, template literals expressions that contain a single identifier won't break anymore:

const foo = `Hello ${username}. Today is ${month} ${day}. You have ${newMessages} new messages`.

Fix formatting of comment inside arrow function (#3334) by @jackyho112

Fixes an edge case where Prettier was moving comments around breaking tools like Webpack:

const API = {
  loader: () => import('./test' /* webpackChunkName: "test" */),
};

// would get formatted to

const API = {
loader: (/ webpackChunkName: "test" /) => import("./test")
};

Fix printing of comments around decorators and class properties (#3382) by @azz

There was a case where comments between a decorator and a class property were moved to an invalid position.

// Before
class Something {
  @decorator
  static // comment
  property = 1;
}

// After
class Something {
@decorator
// comment
static property = 1;
}

Flow

Do not break on empty type parameters (#3281) by @vjeux

It won't break empty type parameters (foo: Type<>) anymore.

Add support for flow mixins when using babylon (#3391) by @bakkot

We were accidentally dropping flow mixins, this has been fixed, but only for the babylon parser.

// Before
class Foo extends Bar {}

// After
class Foo extends Bar mixins Baz {}

TypeScript

Don't print a trailing comma after object rest spread (#3313) by @duailibe

This was inconsistent with JavaScript and Flow, Prettier won't print a trailing comma in the following cases, when using the TypeScript parser:

const {
  bar,
  baz,
  ...rest
} = foo;

Print parens around type assertions for decorators (#3329) by @azz

We were omitting parens around type assertions inside decorators:

@(bind as ClassDecorator)
class Decorated {}

Markdown

Don't break inlineCode (#3230) by @ikatyang

Prettier won't break text inside inlineCode meaning it will only break of after it.

No extra whitespace between non-CJK and CJK-punctuation and vice-versa (#3244, #3249) by @ikatyang

Fixes cases where Prettier would insert extra whitespace like in the following examples:

扩展运算符(spread )是三个点(`...`)。

This is an english paragraph with a CJK quote " 中文 ".

Escape all emphasis-like text (#3246) by @ikatyang

Fixes the case where \_\_text\_\_ would be formatted as __text__.

Handle punctuation variants (#3254) by @ikatyang

Prettier now considers not only ASCII punctuation characters but Unicode as well.

Support TOML front matter (#3290) by @ikatyang

We already supported YAML in the front matter of Markdown files and we added the TOML format as well, since some static site generators support it.

+++
date: '2017-10-10T22:49:47.369Z'
title: 'My Post Title'
categories: ['foo', 'bar']
+++

This is the markdown body of my post.

Only indent the first non-list node in checkbox list item (#3297) by @ikatyang

Fixes a bug where it would indent lines after a list when it shouldn't:

* parent list item
 <span class="pl-v">*</span> child list item

* [x] parent task list item

 <span class="pl-v">*</span> [x] child task list item</pre></div>

would become:

* parent list item

* child list item

* [x] parent task list item

  <span class="pl-v">*</span> [x] child task list item</pre></div>

Preserve non-breaking whitespaces (#3327) by @ikatyang

Non-breaking whitespaces are useful to keep words separated by spaces together in the same line (i.e. number and units or multi-word product names). Prettier was wrongfully converting them to regular whitespaces.

Do not break before special prefix (#3347) by @ikatyang

Fixes a bug where Prettier could break text if it went over the print width right before a number followed by . which would be parsed as a numbered list:

She grew up in an isolated village in the 19th century and met her father aged
29. Oh no, why are we in a numbered list now?

Omit semicolon in simple JSX expressions (#3330) by @sapegin

Prettier will omit the semicolon (before and after) inside code samples if it's a simple JSX expression:

No semi:

jsx</span><span class="pl-s1"></span> <span class="pl-s1">&lt;div&gt;Example&lt;/div&gt;</span> <span class="pl-s1"></span><span class="pl-c1">

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Samples test errors

From master:

$ cd samples
$ npm run test

> @google-cloud/[email protected] test C:\Users\sawch\dev\nodejs-storage\samples
> repo-tools test run --cmd npm -- run cover

run: Executing tests in: C:\Users\sawch\dev\nodejs-storage\samples
run: Running: npm run cover

> @google-cloud/[email protected] cover C:\Users\sawch\dev\nodejs-storage\samples
> nyc --reporter=lcov --cache ava -T 20s --verbose system-test/*.test.js && nyc report


  √ quickstart » should create a bucket (1s)
  - requesterPays » should error on requester-pays requests if they are disabled
  √ encryption » should generate a key (431ms)
  √ buckets » should create a bucket (1.9s)
  √ requesterPays » should fetch requester-pays status on a default bucket (1.1s)
  √ iam » should add multiple members to a role on a bucket (1.6s)
  × files » should upload a file
  × encryption » should upload a file
  √ buckets » should list buckets (1.1s)
  √ requesterPays » should enable requester-pays requests (1.3s)
  √ acl » should print a user's acl for a bucket (2.4s)
  √ iam » should list members of a role on a bucket (1.1s)
  × files » should download a file
  × encryption » should download a file
  √ buckets » should delete a bucket (1.2s)
C:\Users\sawch\dev\nodejs-storage\samples\node_modules\yargs\yargs.js:1057
      else throw err
           ^

Error: This is currently not available using the Cloud Client Library.
    at Object.rotateEncryptionKey [as handler] (C:\Users\sawch\dev\nodejs-storage\samples\encryption.js:59:81)
    at Object.runCommand (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\yargs\lib\command.js:226:22)
    at Object.parseArgs [as _parseArgs] (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\yargs\yargs.js:970:30)
    at Object.parse (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\yargs\yargs.js:538:25)
    at Object.<anonymous> (C:\Users\sawch\dev\nodejs-storage\samples\encryption.js:60:1582)
    at Module._compile (module.js:624:30)
    at Module.replacementCompile (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\nyc\node_modules\append-transform\index.js:58:13)
    at Module.replacementCompile (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\nyc\node_modules\append-transform\index.js:58:13)
    at module.exports (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\nyc\node_modules\default-require-extensions\js.js:8:9)
    at C:\Users\sawch\dev\nodejs-storage\samples\node_modules\nyc\node_modules\append-transform\index.js:62:4
  √ encryption » should rotate keys (411ms)
  √ requesterPays » should fetch requester-pays status on a modified bucket (1.1s)
  √ iam » should remove multiple members from a role on a bucket (1.6s)
  √ acl » should add a user as an owner on a bucket (1.6s)
  √ files » should move a file (1.9s)
  √ requesterPays » should download a file using requester-pays requests (1.3s)
  √ acl » should remove a user from a bucket (1.7s)
  √ requesterPays » should disable requester-pays requests (1.3s)
  √ files » should copy a file (1.8s)
  √ acl » should add a user as a default owner on a bucket (1.3s)
  √ files » should list files (1.1s)
  √ acl » should remove a default user from a bucket (1.3s)
  √ files » should list files by a prefix (2.4s)
  √ acl » should print a user's acl for a file (1.7s)
  √ files » should make a file public (1.3s)
  √ acl » should add a user as an owner on a bucket (1.3s)
  √ files » should generate a signed URL for a file (797ms)
  √ acl » should remove a user from a bucket (1.3s)
  √ files » should get metadata for a file (1s)
  √ acl » should print acl for a bucket (1.1s)
  √ acl » should print acl for a file (1.2s)
  √ files » should delete a file (1.2s)
{ Error: ENOENT: no such file or directory, unlink 'C:\Users\sawch\dev\nodejs-storage\samples\resources\downloaded.txt'
    at Object.fs.unlinkSync (fs.js:1068:18)
    at Test.test.after.always [as fn] (C:\Users\sawch\dev\nodejs-storage\samples\system-test\files.test.js:42:8)
    at Test.callFn (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\test.js:305:18)
    at Test.run (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\test.js:318:23)
    at runNext (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\sequence.js:58:44)
    at Sequence.run (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\sequence.js:90:10)
    at runNext (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\sequence.js:58:44)
    at promise.then.passed (C:\Users\sawch\dev\nodejs-storage\samples\node_modules\ava\lib\sequence.js:86:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'unlink',
  path: 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt' }

  4 tests failed [16:43:52]
  1 test skipped

  encryption » should upload a file

  C:\Users\sawch\dev\nodejs-storage\samples\system-test\encryption.test.js:79

   78:   );
   79:   t.regex(
   80:     results.stdout + results.stderr,

  Value must match expression:

  'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.null'

  Regular expression:

  /File C:\Users\sawch\dev\nodejs-storage\samples\resources\test.txt uploaded to gs:\/\/nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f\/test.txt./

  results.stdout+results.stderr
  => 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.null'

  results.stderr
  => null

  results
  => {
    err: null,
    output: 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.',
    stderr: null,
    stdout: 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.',
  }

  results.stdout
  => 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.'

  results
  => {
    err: null,
    output: 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.',
    stderr: null,
    stdout: 'File C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to gs://nodejs-storage-samples-245817c2-d946-4509-b149-3c423d5c219f/test.txt.',
  }



  encryption » should download a file

  C:\Users\sawch\dev\nodejs-storage\samples\system-test\encryption.test.js:92

   91:   );
   92:   t.regex(
   93:     results.stdout + results.stderr,

  Value must match expression:

  'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.null'

  Regular expression:

  /File test.txt downloaded to C:\Users\sawch\dev\nodejs-storage\samples\resources\downloaded.txt./

  results.stdout+results.stderr
  => 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.null'

  results.stderr
  => null

  results
  => {
    err: null,
    output: 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
    stderr: null,
    stdout: 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
  }

  results.stdout
  => 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.'

  results
  => {
    err: null,
    output: 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
    stderr: null,
    stdout: 'File test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
  }



  files » should upload a file

  C:\Users\sawch\dev\nodejs-storage\samples\system-test\files.test.js:66

   65:   );
   66:   t.regex(
   67:     results.stdout + results.stderr,

  Value must match expression:

  'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.null'

  Regular expression:

  /C:\Users\sawch\dev\nodejs-storage\samples\resources\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8./

  results.stdout+results.stderr
  => 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.null'

  results.stderr
  => null

  results
  => {
    err: null,
    output: 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.',
    stderr: null,
    stdout: 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.',
  }

  results.stdout
  => 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.'

  results
  => {
    err: null,
    output: 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.',
    stderr: null,
    stdout: 'C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\test.txt uploaded to nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8.',
  }



  files » should download a file

  C:\Users\sawch\dev\nodejs-storage\samples\system-test\files.test.js:79

   78:   );
   79:   t.regex(
   80:     results.stdout + results.stderr,

  Value must match expression:

  'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.null'

  Regular expression:

  /gs:\/\/nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8\/test.txt downloaded to C:\Users\sawch\dev\nodejs-storage\samples\resources\downloaded.txt./

  results.stdout+results.stderr
  => 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.null'

  results.stderr
  => null

  results
  => {
    err: null,
    output: 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
    stderr: null,
    stdout: 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
  }

  results.stdout
  => 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.'

  results
  => {
    err: null,
    output: 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
    stderr: null,
    stdout: 'gs://nodejs-storage-samples-4c87f769-65ce-4ae2-8430-5fc286a304f8/test.txt downloaded to C:\\Users\\sawch\\dev\\nodejs-storage\\samples\\resources\\downloaded.txt.',
  }


npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files (x86)\\Nodist\\v-x64\\8.6.0\\node.exe" "C:\\Program Files (x86)\\Nodist\\npmv\\4.0.5\\bin\\npm-cli.js" "run" "cover"
npm ERR! node v8.6.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! @google-cloud/[email protected] cover: `nyc --reporter=lcov --cache ava -T 20s --verbose system-test/*.test.js && nyc report`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @google-cloud/[email protected] cover script 'nyc --reporter=lcov --cache ava -T 20s --verbose system-test/*.test.js && nyc report'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the @google-cloud/storage-samples package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nyc --reporter=lcov --cache ava -T 20s --verbose system-test/*.test.js && nyc report
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @google-cloud/storage-samples
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls @google-cloud/storage-samples
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\sawch\dev\nodejs-storage\samples\npm-debug.log
run: Oh no! Test failed after 28.0s.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] test: `repo-tools test run --cmd npm -- run cover`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @google-cloud/[email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sawch\AppData\Roaming\npm-cache\_logs\2017-10-09T20_43_53_317Z-debug.log

logging endpoint support

From @chrishiestand on June 5, 2017 19:23

I need to be able to programmatically use the storage logging endpoints: https://cloud.google.com/storage/docs/access-logs

(It would be so much nicer to be able to make an API call to get storage usage per bucket rather than create a new bucket, add logging, parse logfiles and so on - but that is a GCP issue, not a google-cloud-node issue.)

I see you are already working on custom endpoint support: googleapis/google-cloud-node#1630

I don't know how far away custom endpoints are, but in any case it would be very useful to me to add google-cloud-node storage logging endpoint support in one form or another.

Copied from original issue: googleapis/google-cloud-node#2359

Feature Request in getFiles: order and filter result

I'm sure it will be useful if we can order result by certain criteria, such as by date, name, or file type either ascending or descending.
In addition, it would be better if we can filter files by name. Therefore only matching files will be returned, not all files in the bucket

Is it possible with the current API provided by Google Cloud Storage? Unfortunately it's not easy to find the API documentation.

Storage API has poor performance in Google Cloud Functions

edit by @stephenplusplus

Follow along in the Google issue tracker: https://issuetracker.google.com/issues/70555688


Environment details

  • Node.js version: v6.11.5
  • @google-cloud/storage version: 1.5.0

Steps to reproduce

The API seems to never reuse connections, which causes Cloud Functions using this API to have poor performance and blow up socket connection and DNS quotas very easily.
In the best practices guide (https://cloud.google.com/functions/docs/bestpractices/networking) they give the NodeJS PubSub as an example, which when declared globally will avoid uncesesary DNS queries and connections.

Could be because the configuration of the requests are hardcoded

forever: false,

Support crypto without a key file

From https://github.com/GoogleCloudPlatform/google-cloud-common/issues/180

Calls requiring crypto, such as file.getSignedUrl() currently do not work automatically-authenticated environments, because values of a service account's JSON key file are required. However, it's possible to query the metadata server for those values:

curl -H 'Metadata-Flavor: Google' -vs 'http://metadata/computeMetadata/v1/instance/service-accounts/default/' 2>&1

Which will give you something like:

aliases
email
scopes
token

Implying

http://metadata/computeMetadata/v1/instance/service-accounts/default/aliases
http://metadata/computeMetadata/v1/instance/service-accounts/default/email
http://metadata/computeMetadata/v1/instance/service-accounts/default/scopes
http://metadata/computeMetadata/v1/instance/service-accounts/default/token

An in-range update of mocha is breaking the build 🚨

Version 3.5.1 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: docs CircleCI is running your tests Details
  • ci/circleci: lint CircleCI is running your tests Details
  • continuous-integration/appveyor/branch AppVeyor build failed Details

Release Notes v3.5.1

3.5.1 / 2017-09-09

📰 News

  • 📣 Mocha is now sponsoring PDXNode! If you're in the Portland area, come check out the monthly talks and hack nights!

🐛 Fixes

  • #2997: Fix missing xit export for "require" interface (@solodynamo)
  • #2957: Fix unicode character handling in XUnit reporter failures (@jkrems)

🔩 Other

Commits

The new version differs by 14 commits.

  • 4070a44 Release v3.5.1
  • 466ba73 update CHANGELOG.md for v3.5.1 [ci skip]
  • 1cc0fc0 import/require xit, fixes #2972
  • 74fa66f update nyc to latest; remove workaround in travis script
  • aa52933 update coveralls strategy; closes #2984
  • 73a5338 Spelling (#2981)
  • 9f403bf Add utils.escape tests and fix unicode escaping
  • 800acbc whitelist "developer-experience" tag for stalebot [ci skip]
  • 5895671 Added issue, pull request templates. (#2869)
  • 075bd51 Merge pull request #2918 from mochajs/no-shell-test
  • 8710438 Work around Node 0.10 Windows flake when testing
  • 13b8340 Ensure that compiler lookup works and not just that transpilation works (#2922)
  • 26d337a Add tests for double-star behavior
  • c0e6b68 Eliminate glob.sh

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

In files.js:copy, rewrite calls only includes userProject on the first request

This is re-posted from an internal ticket. (Googlers: b/68164387)


This causes copy requests to fail.

Repro: Copy a large object across two requester pays buckets in different locations, while acting as a user in a different project. I hacked the source to set query.maxBytesRewrittenPerCall = 1048576 so that I could test with a 2 MiB object.

403 request signature does not match errors with 1.5.0

I have a Google Cloud Function that uses file.getSignedPolicy() and nodejs 6.11. In the package.json I was pointing to 1.2.0 like this:

"@google-cloud/storage": "^1.2.0",

After recently updating the function my browser form POST uploads using getSignedPolicy started failing with the following error:

<?xml version='1.0' encoding='UTF-8'?><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message><StringToSign>eyJleHBpcmF0aW9uIjoiMjAxNy0xMS0yOVQyMjoxNjoyMi4wMDhaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIka2V5IiwiYjc2MzBhZjAtOThjNS00YjgwLTg2OWItMDAwMGY1MWZhNDJlLXJlZGJlYXItc3RvcmUucGRmIl0seyJidWNrZXQiOiJmYXhyb2NrZXQtZGF0YSJ9LFsiZXEiLCIkQ29udGVudC1UeXBlIiwiYXBwbGljYXRpb24vcGRmIl0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDAifSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDIwMDAwMDAwXV19</StringToSign></Error>

Absolutely no change to the cloud function code that was doing the signing or the client upload code. After about an hour of mucking around, I updated the package.json to pin the version to 1.2.0:

"@google-cloud/storage": "1.2.0",

Everything works now. I don't have a clean way to be able to tell what the exact signature difference is, but I looked and realized there was a change in 1.5.0 to the getSignedPolicy function: it is doing something different when deployed in the Google Cloud Functions environment.

As an extra twist, the exact same code with 1.5.0 works when deployed in the function emulator: unfortunately I couldn't figure out how to compare the policy signature output of both versions side by side for the same input.

An in-range update of @google-cloud/nodejs-repo-tools is breaking the build 🚨

Version 2.0.0 of @google-cloud/nodejs-repo-tools just got published.

Branch Build failing 🚨
Dependency @google-cloud/nodejs-repo-tools
Current Version 2.0.0-beta.12
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As @google-cloud/nodejs-repo-tools is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: node8 Your tests failed on CircleCI Details

Commits

The new version differs by 16 commits ahead by 16, behind by 13.

There are 16 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of @google-cloud/common is breaking the build 🚨

Version 0.15.1 of @google-cloud/common was just published.

Branch Build failing 🚨
Dependency @google-cloud/common
Current Version 0.15.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

@google-cloud/common is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ci/circleci: node9 Your tests passed on CircleCI! Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests passed on CircleCI! Details
  • continuous-integration/appveyor/branch AppVeyor build failed Details

Release Notes v0.15.1
  • (#4): Upgrade google-auto-auth.
Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @google-cloud/nodejs-repo-tools is breaking the build 🚨

Version 2.0.11 of @google-cloud/nodejs-repo-tools was just published.

Branch Build failing 🚨
Dependency @google-cloud/nodejs-repo-tools
Current Version 2.0.10
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@google-cloud/nodejs-repo-tools is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: node8 Your tests are queued behind your running builds Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node6 CircleCI is running your tests Details
  • ci/circleci: node4 CircleCI is running your tests Details
  • ci/circleci: node7 Your tests failed on CircleCI Details

Commits

The new version differs by 2 commits.

  • f3fe73d Small fix.
  • f20e86a Successfully ignore the new package-lock.json-12345 files. (#56)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of prettier is breaking the build 🚨

Version 1.7.1 of prettier just got published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.7.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As prettier is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of @google-cloud/pubsub is breaking the build 🚨

Version 0.14.8 of @google-cloud/pubsub was just published.

Branch Build failing 🚨
Dependency @google-cloud/pubsub
Current Version 0.14.7
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@google-cloud/pubsub is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Error : Not Found google cloud storage

From @c00kie17 on August 28, 2017 15:35

OS: Windows10 
Node.js version: 8.4.0
npm version:5.3.0
google-cloud-node  #version:1.2.1
add_file:function(path){
    bucket.upload(path, function(err, file) {
        if (err) {
          console.error(err)
        }
        console.log(file)
    });
  },

thats my function to upload a file the file is a 34 mb .dem protobuf file the error trace im getting is.

Error: Not Found
    at Request._callback (C:\Users\anshu\Desktop\statseeker\node_modules\gcs-resumable-upload\index.js:283:25)
    at Request.self.callback (C:\Users\anshu\Desktop\statseeker\node_modules\request\request.js:188:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (C:\Users\anshu\Desktop\statseeker\node_modules\request\request.js:1171:10)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (C:\Users\anshu\Desktop\statseeker\node_modules\request\request.js:1091:12)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Copied from original issue: googleapis/google-cloud-node#2573

Documentation for nodejs getMetadata doesn't indicate all options

From @tejohnso on November 2, 2017 20:45

Looking for example at getMetadata there's an indication that userProject can be supplied as an option, but there's no indication that we can include any key and it is going to be passed to the underlying request package as part of the qs (querystring) configuration for the request.

So while getMetadata({userProject: true}) might work, getMetadata({fields: "generation"}) also works. This is a minor issue, but it would be nice if it was more clear that what we're really passing as configuration is any querystring value that should be included. Curious to know why userProject is singled out there.

Also, as an aside, the documentation indicates userProject is a boolean.

Copied from original issue: googleapis/google-cloud-node#2718

Feature Request: Upload files to a bucket by passing url in place of a local path.

Create a new method for the Bucket class called uploadFromURL. Said method would work the same way as the upload method, but in place of a local path would take a url (http://exapmle.com/img.jpg).

This eliminates the need for a user to download the file, upload it, then delete it him or her self.

If approved I would build the feature my self and submit a pull request.

No resumable option for getSignedUrl?

From @odigity on April 22, 2017 1:11

I've spent the last week learning about GCS, the SDK, and the Node client library, and just today finally get a prototype working that generated a signed URL on the server and passed it to the browser which used it to PUT a file.

Now I want to tackle resumable uploads for large files, and to my shock, I don't see a way to use the Node lib to make one. I even went into the code of both gsutil and the Node lib to confirm.

gsutil

If you look at the docs for gsutil, it mentions that the -m option takes both the 'GET' and 'RESUMABLE' values (not a very complete list, should probably list all possible values), and later on shows an example with 'PUT', so at least those three are specified.

If you check the code, you'll see that RESUMABLE gets converted to POST, and an x-goog-resumable header is used. Also here you'll see that all values are rejected except [ 'GET', 'PUT', 'DELETE', 'HEAD', 'RESUMABLE' ].

Node.js Library

Now take a look at the docs for getSignedUrl in the Node lib. The action option takes three values ('read', 'write', 'delete') which it says are equivalent to 'GET', 'PUT', and 'DELETE' respectively. (Not sure why these special read/write/delete values are invented for the Node lib, it just adds confusion.)

Then in the code you can see that no other values are allowed.


So, the question is: How do I use the Node lib to generate a signed URL for a resumable upload?

Copied from original issue: googleapis/google-cloud-node#2248

Invalid Expires property when generating a signed URL to write and read to in the @google-cloud/storage package

Is anyone having issues with generating a valid signed url for Cloud Storage? I'm getting the following error when I try to PUT to the final URL.

<?xml version='1.0' encoding='UTF-8'?>
<Error>
    <Code>InvalidArgument</Code>
    <Message>Invalid argument.</Message>
    <Details>Expires parameter is not a valid long value: NaN</Details>
</Error>

Looking at the URL, it contains Expires=NaN. Even without an expires property in the getSignedUrl config it still says NaN.

Long shot, but manually setting the expires property gives me the following error.

<?xml version='1.0' encoding='UTF-8'?>
<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
    <StringToSign>PUT

video/mp4
1508619214
/xxx-xxx/D48641F8-D1BC-424E-8115-FB1BD3599B89_f9f2537d-cedf-443e-b1da-0c32031d16b0.mp4</StringToSign>
</Error>

Environment details

  • OS: macOS 10.3.1 Beta
  • Node.js version: v8.4.0
  • npm yarn version: 0.18.1
  • google-cloud-node version: 1.4.0

Steps to reproduce

  1. require @google-cloud/storage
  2. Create a new storage object
        const storage = Storage({
            projectId: 'your-project',
            keyFilename: appConfig.gcloud.credentials(),
        });
  1. Request a signed URL
        const expires = moment();
        expires.add(7, 'days');
        result = await storage
                        .bucket('your-bucket')
                        .file('myfile.mp4')
                        .getSignedUrl({
                            action: 'write',
                            expires: expires.format('DD-MM-YYYY'),
                            contentType: 'video/mp4',
                        });
  1. PUT to the signed URL with Postman with header values and a video as a binary in the body.
[{"key":"Content-Type","value":"video/mp4","description":""}]

extensionHeaders in method File.getSignedUrl do not work as expected

From @teemeh on August 25, 2017 14:41

It's only noted in the documentation that the "extensionHeaders" needs to be an object with not a single example or link. While not using such key-value pair in config object, I can easily retrieve the file, setting a self-defined header in way described below, which I believe is the most common way, doesn't allow me to retrieve the file anymore with the error message "The request signature we calculated does not match the signature you provided."

Environment details

  • OS: ubuntu
  • Node.js version: v6.11.2
  • npm version: irrelavent
  • google-cloud-node version: latest

Steps to reproduce

1.var myHeaders = { myHeader: "myHeader"};
2.Then inside the config object, we have the key-value pair extensionHeaders: myHeaders,.
The config object then is fed to File.getSignedUrl().

No matter how I try (node.js request module or curl), the uncommented key-value pair (step 2) will always cause error, whereas the error is gone as soon as I comment that one line out in step 2 (logically, it doesn't matter if I delete the customized request header when doing the request). Not sure if it's the server's problem or google-cloud-node.

Copied from original issue: googleapis/google-cloud-node#2559

An in-range update of @google-cloud/nodejs-repo-tools is breaking the build 🚨

Version 2.1.3 of @google-cloud/nodejs-repo-tools was just published.

Branch Build failing 🚨
Dependency @google-cloud/nodejs-repo-tools
Current Version 2.1.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@google-cloud/nodejs-repo-tools is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • continuous-integration/appveyor/branch AppVeyor build succeeded Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node9 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

Commits

The new version differs by 8 commits.

  • b713f64 2.1.3
  • 6283a7e chore(package): update eslint to version 4.11.0 (#78)
  • 00524d0 Add ability to specify test url in config file (without using a global env var) (#81)
  • 5255583 Add E2E_URL env var for manually specifying request endpoint (#76)
  • ccee0b8 Update to newest Node 6 version (#77)
  • 5aa6090 fix(package): update sinon to version 4.1.0 (#72)
  • 4b5855d fix(package): update nyc to version 11.3.0 (#71)
  • 2fb0d84 chore(package): update eslint-config-prettier to version 2.7.0 (#69)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Example instantiations don't use `new`

@jmdobry -- do we want to put news in front of these instantiations? This is from the README.

// Imports the Google Cloud client library
const Storage = require('@google-cloud/storage');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Instantiates a client
const storage = Storage({
  projectId: projectId,
});

Installation fails via npm

Install fails using npm install --save @google-cloud/storage

Error log:
npm install --save @google-cloud/storage npm ERR! 404 Not Found npm ERR! 404 npm ERR! 404 'google-cloud/storage' is not in the npm registry. npm ERR! 404 You should bug the author to publish it

Cloning via git:
git clone [email protected]:google-cloud/storage storage Cloning into storage... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

files.js:createReadStream doesn't include userProject when calling getMetadata

This is reposted from an internal issue. (Googlers: b/68164122)


In project A, create requester-pays bucket my-bucket and with IAM roles allUsers:legacyBucketOwner,objectAdmin

In project B add user U to a role with serviceusage.services.use permission.

Use the requesterPays sample to read an object in my-bucket with credentials for user U.

  • Expected: download succeeds
  • Actual: download fails

Hacking the invocation of getMetadata to include the userProject worked for me.

files.js:createReadStream doesn't include userProject when calling getMetadata

In project A, create requester-pays bucket my-bucket and with IAM roles allUsers:legacyBucketOwner,objectAdmin

In project B add user U to a role with serviceusage.services.use permission.

Use the requesterPays sample to read an object in my-bucket with credentials for user U.

Expected: download succeeds
Actual: download fails

Could not authenticate request

Hi,

I am trying to upload a file to my google cloud storage bucket, but i am receiving the error below.

Error: Could not authenticate request
ENOENT: no such file or directory, open '/var/www/project/server/{'
at wrapError (/var/www/project/server/node_modules/gcs-resumable-upload/index.js:24:10)
at /var/www/project/server/node_modules/gcs-resumable-upload/index.js:274:30
at getToken (/var/www/project/server/node_modules/google-auto-auth/index.js:24:9)
at getAuthClient (/var/www/project/server/node_modules/google-auto-auth/index.js:178:9)
at

Environment details

  • OS: Ubuntu 16.04
  • Node.js version: v8.9.3
  • npm version: 5.5.1
  • google-cloud/storage: "^1.5.1",

Steps to reproduce

let Config = require('../../config/app');
let Storage = require('@google-cloud/storage');

class GoogleCloudStorage {

    constructor() {

        this.bucketName = Config.filesystem.google.bucket;

        this.storage = new Storage({
            projectId: Config.filesystem.google.projectId,
            keyFilename: Config.filesystem.google.service_account_key,
        });
    }

    sendUploadToGCS(req, res, next) {

        if (!req.file) {
            return next();
        }

        console.log(req.file);

        const gcsname = Date.now() + req.file.originalname;
        const file = this.storage.bucket(this.bucketName).file(gcsname);
        console.log(file);

        const stream = file.createWriteStream({
            metadata: {
                contentType: req.file.mimetype,
            },
        });

        stream.on('error', (err) => {
            req.file.cloudStorageError = err;
            next(err);
        });

        stream.on('finish', () => {
            req.file.cloudStorageObject = gcsname;
            file.makePublic().then(() => {
                req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
                next();
            });
        });

        stream.end(req.file.buffer);
    }

    getPublicUrl(filename) {
        return 'https://storage.googleapis.com/' + this.bucketName + '/' + filename;
    }


}
module.exports = GoogleCloudStorage;

app.use('/upload', m.single('avatar'), storage.sendUploadToGCS.bind(storage), (req, res) => {
    console.log(req.file);
    return res.json('1');
});

add a bucket#getDirectories() helper method

From @esprehn on September 5, 2017 21:1

Environment details

  • OS: OS X
  • Node.js version: v6.10.3
  • npm version: 3.10.10
  • google-cloud-node version: 1.2.1

Steps to reproduce

  1. require google-cloud
bucket.getFiles({ delimiter: '/' }, function(err, files, nextQuery, api) {
  console.log(err, files, nextQuery, api);
});

Will print null [] undefined undefined.

This is very confusing, it seems you need to pass autoPaginate: false to get the api response back.

Looking at the code I don't know where this happens, the code does:

    var nextQuery = null;
    if (resp.nextPageToken) {
      nextQuery = extend({}, query, {
        pageToken: resp.nextPageToken
      });
    }

    callback(null, files, nextQuery, resp);

And if you console.log(resp) here it's non-undefined, but by the time it gets to your callback it's undefined. Where did the extra arguments end up?

Note also that while other apis return the ApiResponse in the second position of the array, getFiles does't so you can't do:

const [files, api] = await bucket.getFiles({ delimiter: '/' });
console.log(api.prefixes);

and instead you must pass a callback.

Copied from original issue: googleapis/google-cloud-node#2594

Pumpify.Deplexify.end Error

Version ^1.2.1

I keep getting this error when trying to load files to Cloud Storage:

TypeError: Cannot read property 'ending' of undefined
    at Pumpify.Duplexify.end (/home/matt/Projects/Code/workbox/node_modules/duplexify/index.js:224:28)
    at Pumpify.Duplexify.setWritable (/home/matt/Projects/Code/workbox/node_modules/duplexify/index.js:82:10)
    at Pumpify.setPipeline (/home/matt/Projects/Code/workbox/node_modules/pumpify/index.js:47:10)
    at new Pumpify (/home/matt/Projects/Code/workbox/node_modules/pumpify/index.js:15:30)
    at Pumpify (/home/matt/Projects/Code/workbox/node_modules/pumpify/index.js:13:44)
    at File.createWriteStream (/home/matt/Projects/Code/workbox/node_modules/@google-cloud/storage/src/file.js:915:5)
    at upload (/home/matt/Projects/Code/workbox/node_modules/@google-cloud/storage/src/bucket.js:2236:21)
    at /home/matt/Projects/Code/workbox/node_modules/@google-cloud/storage/src/bucket.js:2229:7
    at FSReqWrap.oncomplete (fs.js:153:5)

An in-range update of prettier is breaking the build 🚨

Version 1.8.0 of prettier was just published.

Branch Build failing 🚨
Dependency prettier
Current Version 1.7.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

Release Notes 1.8.0: Markdown Support

image

This release adds Markdown support, a new --insert-pragma flag, fixes a number of formatting issues, adds support for some new experimental operators, and improves our editor integration support.

Highlights

Markdown Support

Support markdown (#2943) by @ikatyang

You can now run Prettier on Markdown files! 🎉

The implementation is highly compliant with the CommonMark spec, and backed by the excellent remark-parse package.

Word Wrap

One of Prettier's core features is its ability to wrap code at a specified line length. This applies to Markdown too, which means you can maintain nice and clean 80-character-wide Markdown files without having to re-adjust line breaks manually when you add or delete words.

Input:

Voilà! In view, a humble vaudevillian veteran cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valourous visitation of a bygone vexation stands vivified and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition! The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honour to meet you and you may call me V.

Output:

Voilà! In view, a humble vaudevillian veteran cast vicariously as both victim
and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity,
is a vestige of the vox populi, now vacant, vanished. However, this valourous
visitation of a bygone vexation stands vivified and has vowed to vanquish these
venal and virulent vermin vanguarding vice and vouchsafing the violently vicious
and voracious violation of volition! The only verdict is vengeance; a vendetta
held as a votive, not in vain, for the value and veracity of such shall one day
vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage
veers most verbose, so let me simply add that it's my very good honour to meet
you and you may call me V.

Note for CJK users: If your markdown renderer does not support CJK line ending, you'll have to use plugin like markdown-it-perfect-newline-for-cjk, hexo-filter-fix-cjk-spacing, etc. to remove additional spaces.

// Source
一二三
四五六
七八九

// Rendered content with unsupported renderer
一二三 四五六 七八九

// Rendered content with supported renderer or via plugin
一二三四五六七八九

Code Formatting

Powered by Prettier's generic "multiparser", Prettier will format code blocks in Markdown! We use the language code provided with the code block to determine which language it is, and thus we can format any language that Prettier supports (including Markdown itself, if you're into that).

Input:

```js
reallyUgly    (
javascript
  )
```
.h1 {     color : red }
```</pre></div>
<p>Output:</p>
<div class="highlight highlight-source-lisp"><pre>```js
reallyUgly(javascript)<span class="pl-c"><span class="pl-c">;</span></span>
.h1 {
  color: red<span class="pl-c"><span class="pl-c">;</span></span>
}
```</pre></div>
<blockquote>
<p>Note: In some cases you may not want to format your code in Markdown, and just like in other languages, in Markdown you can use <code>&lt;!-- prettier-ignore --&gt;</code> before the code block to ignore it from formatting.</p>
</blockquote>
<p><strong>Lists</strong></p>
<p>When rearranging list items, after running Prettier all the numbers will be fixed!</p>
<p><a href="https://camo.githubusercontent.com/50f76500c503763c50019ad61ff531716ff7f3c9/687474703a2f2f672e7265636f726469742e636f2f4d4174616e5a4d5a526f2e676966" target="_blank"><img src="https://camo.githubusercontent.com/50f76500c503763c50019ad61ff531716ff7f3c9/687474703a2f2f672e7265636f726469742e636f2f4d4174616e5a4d5a526f2e676966" alt="Markdown Lists" style="max-width:100%;"></a></p>
<blockquote>
<p>Note: you can actually opt out of this by using <code>1.</code> for all list items if you want to optimize for cleaner diffs.</p>
</blockquote>
<p><strong>Tables</strong></p>
<p>Tables will also automatically be adjusted to fit their contents. This could be completely unmaintainable without an automated tool.</p>
<p><a href="https://camo.githubusercontent.com/7f33126347f155262873500e5068016d2e71a773/687474703a2f2f672e7265636f726469742e636f2f33356a61383836636b542e676966" target="_blank"><img src="https://camo.githubusercontent.com/7f33126347f155262873500e5068016d2e71a773/687474703a2f2f672e7265636f726469742e636f2f33356a61383836636b542e676966" alt="Markdown Tables" style="max-width:100%;"></a></p>
<p><strong>Markdown-in-JS</strong></p>
<p>By using either <code>md</code> or <code>markdown</code> tagged template literals, you can format markdown code inside JavaScript.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-c1">markdown</span> <span class="pl-k">=</span> md<span class="pl-s"><span class="pl-pds">`</span></span>
<span class="pl-s">  # heading</span>
<span class="pl-s"></span>
<span class="pl-s">  1. list item</span>
<span class="pl-s"><span class="pl-pds">`</span></span>;</pre></div>
<h2>CLI</h2>
<h3>Add option to insert <code>@format</code> to first docblock if absent (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2865" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="258974830" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2865">#2865</a>) by <a href="https://urls.greenkeeper.io/samouri" class="user-mention">@samouri</a></h3>
<p>In 1.7, we added an option called <code>--require-pragma</code> to require files contain an <code>/** @format */</code> pragma to be formatted. In order to add this pragma to a large set of files you can now use <a href="https://prettier.io/docs/en/cli.html#insert-pragma"><code>--insert-pragma</code></a> flag.</p>
<pre><code>prettier --write "folder/**/*.js" --insert-pragma
</code></pre>
<h3>Add <code>--loglevel</code> option (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2992" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="263707174" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2992">#2992</a>) by <a href="https://urls.greenkeeper.io/ikatyang" class="user-mention">@ikatyang</a></h3>
<p>This <a href="https://prettier.io/docs/en/cli.html#loglevel">nifty feature</a> allows you to opt in (or out) of Prettier's logging. We've also cleaned up the logging substantially since 1.7.</p>
<div class="highlight highlight-source-shell"><pre>$ prettier --loglevel=debug blarg
$ ./bin/prettier.js --loglevel=debug blarg
[debug] normalized argv: {<span class="pl-s"><span class="pl-pds">"</span>_<span class="pl-pds">"</span></span>:[<span class="pl-s"><span class="pl-pds">"</span>blarg<span class="pl-pds">"</span></span>],<span class="pl-s"><span class="pl-pds">"</span>bracket-spacing<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>color<span class="pl-pds">"</span></span>:true,<span class="pl-s"><span class="pl-pds">"</span>debug-check<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>debug-print-doc<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>flow-parser<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>insert-pragma<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>jsx-bracket-same-line<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>list-different<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>require-pragma<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>semi<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>single-quote<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>stdin<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>use-tabs<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>version<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>with-node-modules<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>write<span class="pl-pds">"</span></span>:false,<span class="pl-s"><span class="pl-pds">"</span>loglevel<span class="pl-pds">"</span></span>:<span class="pl-s"><span class="pl-pds">"</span>debug<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>ignore-path<span class="pl-pds">"</span></span>:<span class="pl-s"><span class="pl-pds">"</span>.prettierignore<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>config-precedence<span class="pl-pds">"</span></span>:<span class="pl-s"><span class="pl-pds">"</span>cli-override<span class="pl-pds">"</span></span>}
[error] No matching files. Patterns tried: blarg <span class="pl-k">!</span><span class="pl-k">**</span>/node_modules/<span class="pl-k">**</span> <span class="pl-k">!</span>./node_modules/<span class="pl-k">**</span>
</pre></div>
<h2>JavaScript</h2>
<h3>Fix indentation for JSDoc comments (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2470" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="242554023" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2470">#2470</a>) by <a href="https://urls.greenkeeper.io/maxdeviant" class="user-mention">@maxdeviant</a></h3>
<p>This has been a long-time known issue with Prettier. When formatting code that results in a change of indentation level, the JSDoc comments would end up being out of alignment. We're happy to report this is now fixed!</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">function</span> <span class="pl-en">theFunction2</span>(<span class="pl-smi">action$</span>, <span class="pl-smi">store</span>) {
  <span class="pl-c"><span class="pl-c">/*</span></span>
<span class="pl-c">     * comments</span>
<span class="pl-c">     <span class="pl-c">*/</span></span>
  <span class="pl-k">return</span> <span class="pl-c1">true</span>;
}

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">function</span> <span class="pl-en">theFunction2</span>(<span class="pl-smi">action$</span>, <span class="pl-smi">store</span>) {
  <span class="pl-c"><span class="pl-c">/*</span></span>
<span class="pl-c">   * comments</span>
<span class="pl-c">   <span class="pl-c">*/</span></span>
  <span class="pl-k">return</span> <span class="pl-c1">true</span>;
}</pre></div>
<h3>Print pipeline and nullish-coalescing operators (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3036" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="265544605" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3036">#3036</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>We've added support for two new proposed operators to Prettier: the <em>pipeline operator</em> and the <em>nullish coalescing operator</em>.</p>
<p>The <a href="https://urls.greenkeeper.io/tc39/proposal-pipeline-operator/">pipeline operator</a> is currently a stage one proposal.</p>
<blockquote>
<p>This proposal introduces a new operator |&gt; similar to F#, OCaml, Elixir, Elm, Julia, Hack, and LiveScript, as well as UNIX pipes. It's a backwards-compatible way of streamlining chained function calls in a readable, functional manner, and provides a practical alternative to extending built-in prototypes.</p>
</blockquote>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">let</span> result <span class="pl-k">=</span> <span class="pl-en">exclaim</span>(<span class="pl-en">capitalize</span>(<span class="pl-en">doubleSay</span>(<span class="pl-s"><span class="pl-pds">"</span>hello<span class="pl-pds">"</span></span>)));

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">let</span> result <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>hello<span class="pl-pds">"</span></span>
  <span class="pl-k">|</span><span class="pl-k">&gt;</span> doubleSay
  <span class="pl-k">|</span><span class="pl-k">&gt;</span> capitalize
  <span class="pl-k">|</span><span class="pl-k">&gt;</span> exclaim;</pre></div>
<p>The <a href="https://urls.greenkeeper.io/tc39-transfer/proposal-nullish-coalescing">nullish coalescing operator</a> is another stage one proposal.</p>
<blockquote>
<p>When performing optional property access in a nested structure in conjunction with the optional chaining operator, it is often desired to provide a default value if the result of that property access is null or undefined.</p>
</blockquote>
<p>This operator is similar to <code>||</code> except it only evaluates the right-hand-side if the left is <code>undefined</code> or <code>null</code>, not <code>""</code>, <code>0</code>, <code>NaN</code>, etc.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-c1">foo</span> <span class="pl-k">=</span> <span class="pl-smi">object</span>.<span class="pl-smi">foo</span> <span class="pl-k">??</span> <span class="pl-s"><span class="pl-pds">"</span>default<span class="pl-pds">"</span></span>;</pre></div>
<h3>Improved template literal expresions line breaks (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3124" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="269808048" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3124">#3124</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>This was another known issue with Prettier, when printing a template literal string with expressions inside that went over the print width, it would wrap the code in weird places inside the expressions. Now, if Prettier needs to insert a line break, it should happen right between <code>${</code> and <code>}</code>.</p>
<div class="highlight highlight-source-js-jsx"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">const</span> <span class="pl-smi">description</span><span class="pl-k"> =</span><span class="pl-s"> <span class="pl-s">`</span><span class="pl-s">The value of the <span class="pl-e">${<span class="pl-smi">cssName</span>}</span> css of the <span class="pl-e">${<span class="pl-c1">this</span></span></span></span>
<span class="pl-s"><span class="pl-s"><span class="pl-e">  <span class="pl-k">.</span><span class="pl-smi">_name</span>}</span> element</span><span class="pl-s">`</span></span>;

<span class="pl-k">const</span> <span class="pl-smi">foo</span><span class="pl-k"> =</span><span class="pl-s"> <span class="pl-s">`</span><span class="pl-s">mdl-textfield mdl-js-textfield <span class="pl-e">${<span class="pl-smi">className</span>}</span> <span class="pl-e">${<span class="pl-smi">content</span><span class="pl-k">.</span><span class="pl-smi">length</span><span class="pl-k"> &gt;</span> <span class="pl-c1">0</span></span></span></span>
<span class="pl-s"><span class="pl-s"><span class="pl-e">  <span class="pl-k">?</span> <span class="pl-s"><span class="pl-pds">"</span>is-dirty<span class="pl-pds">"</span></span></span></span></span>
<span class="pl-s"><span class="pl-s"><span class="pl-e">  <span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>}</span> combo-box__input</span><span class="pl-s">`</span></span>;

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">const</span> <span class="pl-smi">description</span><span class="pl-k"> =</span><span class="pl-s"> <span class="pl-s">`</span><span class="pl-s">The value of the \${cssName} css of the \${</span></span>
<span class="pl-s"><span class="pl-s">  this._name</span></span>
<span class="pl-s"><span class="pl-s">} element</span><span class="pl-s">`</span></span>;

<span class="pl-k">const</span> <span class="pl-smi">foo</span><span class="pl-k"> =</span><span class="pl-s"> <span class="pl-s">`</span><span class="pl-s">mdl-textfield mdl-js-textfield <span class="pl-e">${<span class="pl-smi">className</span>}</span> <span class="pl-e">${</span></span></span>
<span class="pl-s"><span class="pl-s"><span class="pl-e"><span class="pl-smi">  content</span><span class="pl-k">.</span><span class="pl-smi">length</span><span class="pl-k"> &gt;</span> <span class="pl-c1">0</span> <span class="pl-k">?</span> <span class="pl-s"><span class="pl-pds">'</span>is-dirty<span class="pl-pds">'</span></span> <span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span><span class="pl-pds">'</span></span></span></span></span>
<span class="pl-s"><span class="pl-s"><span class="pl-e">}</span> combo-box__input</span><span class="pl-s">`</span></span></pre></div>
<h2>JSX</h2>
<h3>Don't inline trailing <code>}</code> for arrow functions attributes (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3110" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="268739661" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3110">#3110</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>In order to align closer to the <a href="https://urls.greenkeeper.io/airbnb/javascript/">Airbnb style guide</a>, and since it was never intentionally printed this way, we've moved the <code>}</code> from to the next line in JSX. This is more diff friendly, and makes it easier to move code around by shifting lines in your editor.</p>
<div class="highlight highlight-source-js-jsx"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
&lt;<span class="pl-ent"><span class="pl-c1">BookingIntroPanel</span></span>
  <span class="pl-e">logClick</span><span class="pl-k">=</span><span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">data</span> <span class="pl-k">=&gt;</span></span>
<span class="pl-s1">    <span class="pl-en">doLogClick</span>(<span class="pl-s"><span class="pl-pds">"</span>long_name_long_name_long_name<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>long_name_long_name_long_name<span class="pl-pds">"</span></span>,<span class="pl-smi"> data</span>)</span><span class="pl-pse">}</span>
/&gt;;

<span class="pl-c"><span class="pl-c">//</span> After</span>
&lt;<span class="pl-ent"><span class="pl-c1">BookingIntroPanel</span></span>
  <span class="pl-e">logClick</span><span class="pl-k">=</span><span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">data</span> <span class="pl-k">=&gt;</span></span>
<span class="pl-s1">    <span class="pl-en">doLogClick</span>(<span class="pl-s"><span class="pl-pds">"</span>long_name_long_name_long_name<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>long_name_long_name_long_name<span class="pl-pds">"</span></span>,<span class="pl-smi"> data</span>)</span>
<span class="pl-s1">  </span><span class="pl-pse">}</span>
/&gt;;</pre></div>
<h1>Other Changes</h1>
<h2>JavaScript</h2>
<h3>Make the factory detection handle multiple elements (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3112" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="268967545" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3112">#3112</a>) by <a href="https://urls.greenkeeper.io/vjeux" class="user-mention">@vjeux</a></h3>
<p>There was a bug in the heuristic that Prettier uses to determine whether an expression is a factory or not. It now works correctly with longer member expressions.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-c1">window</span>.<span class="pl-smi">FooClient</span>
  .<span class="pl-en">setVars</span>({
    locale<span class="pl-k">:</span> <span class="pl-en">getFooLocale</span>({ page }),
    authorizationToken<span class="pl-k">:</span> <span class="pl-smi">data</span>.<span class="pl-smi">token</span>
  })
  .<span class="pl-en">initVerify</span>(<span class="pl-s"><span class="pl-pds">"</span>foo_container<span class="pl-pds">"</span></span>);

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-c1">window</span>.<span class="pl-smi">FooClient</span>.<span class="pl-en">setVars</span>({
  locale<span class="pl-k">:</span> <span class="pl-en">getFooLocale</span>({ page }),
  authorizationToken<span class="pl-k">:</span> <span class="pl-smi">data</span>.<span class="pl-smi">token</span>
}).<span class="pl-en">initVerify</span>(<span class="pl-s"><span class="pl-pds">"</span>foo_container<span class="pl-pds">"</span></span>);</pre></div>
<h3>Handle comments between function name and open paren (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2979" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="263070152" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2979">#2979</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>Printing comments in the right place is an endless challenge <g-emoji alias="wink" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f609.png" ios-version="6.0">😉</g-emoji>. This fix ensures that comments next to function names are re-printed correctly.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">function</span> <span class="pl-en">f</span>(<span class="pl-c"><span class="pl-c">/*</span> comment<span class="pl-c">*/</span></span> <span class="pl-smi">promise</span>) {}

<span class="pl-c"><span class="pl-c">//</span> After </span>
<span class="pl-k">function</span> f <span class="pl-c"><span class="pl-c">/*</span> comment<span class="pl-c">*/</span></span>(<span class="pl-smi">promise</span>) {}</pre></div>
<h3>Support sequential CallExpressions in member chains (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2990" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="263677479" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2990">#2990</a>) by <a href="https://urls.greenkeeper.io/chrisvoll" class="user-mention">@chrisvoll</a></h3>
<p>Member chains are one of the most complex parts of Prettier. This PR fixes an issue where repeated calls lead to the next method not being pushed to the next line.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
wrapper
  .<span class="pl-c1">find</span>(<span class="pl-s"><span class="pl-pds">"</span>SomewhatLongNodeName<span class="pl-pds">"</span></span>)
  .<span class="pl-en">prop</span>(<span class="pl-s"><span class="pl-pds">"</span>longPropFunctionName<span class="pl-pds">"</span></span>)().<span class="pl-en">then</span>(<span class="pl-k">function</span>() {
  <span class="pl-en">doSomething</span>();
});

<span class="pl-c"><span class="pl-c">//</span> After</span>
wrapper
  .<span class="pl-c1">find</span>(<span class="pl-s"><span class="pl-pds">"</span>SomewhatLongNodeName<span class="pl-pds">"</span></span>)
  .<span class="pl-en">prop</span>(<span class="pl-s"><span class="pl-pds">"</span>longPropFunctionName<span class="pl-pds">"</span></span>)()
  .<span class="pl-en">then</span>(<span class="pl-k">function</span>() {
    <span class="pl-en">doSomething</span>();
  });</pre></div>
<h3>Account for empty lines in long member call chain (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3035" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="265515302" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3035">#3035</a>) by <a href="https://urls.greenkeeper.io/jackyho112" class="user-mention">@jackyho112</a></h3>
<p>Previously, Prettier would delete all newlines within a member chain. Now we keep up to one if it's in the source. This is nice for fluent APIs that you want to break up over multiple lines.</p>
<div class="highlight highlight-source-js"><pre>angular
  .<span class="pl-en">module</span>(<span class="pl-s"><span class="pl-pds">"</span>AngularAppModule<span class="pl-pds">"</span></span>)

  <span class="pl-c"><span class="pl-c">//</span> Constants.</span>
  .<span class="pl-en">constant</span>(<span class="pl-s"><span class="pl-pds">"</span>API_URL<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>http://localhost:8080/api<span class="pl-pds">"</span></span>)

  <span class="pl-c"><span class="pl-c">//</span> App configuration.</span>
  .<span class="pl-en">config</span>(appConfig)
  .<span class="pl-en">run</span>(appRun);</pre></div>
<h3>Fix issue where first argument is left behind when line breaks (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3079" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267371127" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3079">#3079</a>) by <a href="https://urls.greenkeeper.io/mutdmour" class="user-mention">@mutdmour</a></h3>
<p>This addresses an issue where due to our special object inline behaviour, the indentation missing from the function call.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-smi">db</span>.<span class="pl-en">collection</span>(<span class="pl-s"><span class="pl-pds">"</span>indexOptionDefault<span class="pl-pds">"</span></span>).<span class="pl-en">createIndex</span>({ a<span class="pl-k">:</span> <span class="pl-c1">1</span> },
{
  indexOptionDefaults<span class="pl-k">:</span> <span class="pl-c1">true</span>
},
<span class="pl-k">function</span>(<span class="pl-smi">err</span>) {
  <span class="pl-c"><span class="pl-c">//</span> code</span>
});

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-smi">db</span>.<span class="pl-en">collection</span>(<span class="pl-s"><span class="pl-pds">"</span>indexOptionDefault<span class="pl-pds">"</span></span>).<span class="pl-en">createIndex</span>(
  { a<span class="pl-k">:</span> <span class="pl-c1">1</span> },
  {
    indexOptionDefaults<span class="pl-k">:</span> <span class="pl-c1">true</span>
  },
  <span class="pl-k">function</span>(<span class="pl-smi">err</span>) {
    <span class="pl-c"><span class="pl-c">//</span> code</span>
  }
);</pre></div>
<h3>Break parens for binaries in member expression (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2958" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="262164203" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2958">#2958</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>Similarly, there was another edge case where indentation was missing from logical expressions. This is fixed, too.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">const</span> <span class="pl-c1">someLongVariable</span> <span class="pl-k">=</span> (<span class="pl-en">idx</span>(
  <span class="pl-c1">this</span>.<span class="pl-smi">props</span>,
  <span class="pl-smi">props</span> <span class="pl-k">=&gt;</span> <span class="pl-smi">props</span>.<span class="pl-smi">someLongPropertyName</span>
) <span class="pl-k">||</span> []
).<span class="pl-en">map</span>(<span class="pl-smi">edge</span> <span class="pl-k">=&gt;</span> <span class="pl-smi">edge</span>.<span class="pl-smi">node</span>);

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">const</span> <span class="pl-c1">someLongVariable</span> <span class="pl-k">=</span> (
  <span class="pl-en">idx</span>(<span class="pl-c1">this</span>.<span class="pl-smi">props</span>, <span class="pl-smi">props</span> <span class="pl-k">=&gt;</span> <span class="pl-smi">props</span>.<span class="pl-smi">someLongPropertyName</span>) <span class="pl-k">||</span> []
).<span class="pl-en">map</span>(<span class="pl-smi">edge</span> <span class="pl-k">=&gt;</span> <span class="pl-smi">edge</span>.<span class="pl-smi">node</span>);</pre></div>
<h3>Prevent breaking MemberExpression inside NewExpression (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3075" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267232001" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3075">#3075</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>There are so many ways to break a line. Some of them look much worse than others. Breaking between in this case looked really weird, so it has been fixed!</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-k">function</span> <span class="pl-en">functionName</span>() {
  <span class="pl-k">if</span> (<span class="pl-c1">true</span>) {
    <span class="pl-c1">this</span>.<span class="pl-smi">_aVeryLongVariableNameToForceLineBreak</span> <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">this</span>
      .<span class="pl-en">Promise</span>((<span class="pl-smi">resolve</span>, <span class="pl-smi">reject</span>) <span class="pl-k">=&gt;</span> {
        <span class="pl-c"><span class="pl-c">//</span> do something</span>
      });
  }
}

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">function</span> <span class="pl-en">functionName</span>() {
  <span class="pl-k">if</span> (<span class="pl-c1">true</span>) {
    <span class="pl-c1">this</span>.<span class="pl-smi">_aVeryLongVariableNameToForceLineBreak</span> <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">this.Promise</span>(
      (<span class="pl-smi">resolve</span>, <span class="pl-smi">reject</span>) <span class="pl-k">=&gt;</span> {
        <span class="pl-c"><span class="pl-c">//</span> do something</span>
      }
    );
  }
}</pre></div>
<h3>Fix array acessors in method chains (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3137" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="270637812" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3137">#3137</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>In a method chain we split lines by grouping elements together and accessing an array should be printed in the end of a group instead of the beginning.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-en">find</span>(<span class="pl-s"><span class="pl-pds">'</span>.org-lclp-edit-copy-url-banner__link<span class="pl-pds">'</span></span>)
  [<span class="pl-c1">0</span>].<span class="pl-c1">getAttribute</span>(<span class="pl-s"><span class="pl-pds">'</span>href<span class="pl-pds">'</span></span>)
  .<span class="pl-c1">indexOf</span>(<span class="pl-c1">this</span>.<span class="pl-smi">landingPageLink</span>)

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-en">find</span>(<span class="pl-s"><span class="pl-pds">'</span>.org-lclp-edit-copy-url-banner__link<span class="pl-pds">'</span></span>)[<span class="pl-c1">0</span>]
  .<span class="pl-c1">getAttribute</span>(<span class="pl-s"><span class="pl-pds">'</span>href<span class="pl-pds">'</span></span>)
  .<span class="pl-c1">indexOf</span>(<span class="pl-c1">this</span>.<span class="pl-smi">landingPageLink</span>)</pre></div>
<h2>Flow and TypeScript</h2>
<h3>Fix indentation of intersection object types (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3074" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267225804" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3074">#3074</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>This was a minor alignment bug in intersection types, and has now been fixed.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
type intersectionTest <span class="pl-k">=</span> {
  propA<span class="pl-k">:</span> <span class="pl-c1">X</span>
} <span class="pl-k">&amp;</span> {
  propB<span class="pl-k">:</span> <span class="pl-c1">X</span>
} <span class="pl-k">&amp;</span> {
    propC<span class="pl-k">:</span> <span class="pl-c1">X</span>
  } <span class="pl-k">&amp;</span> {
    propD<span class="pl-k">:</span> <span class="pl-c1">X</span>
  };

<span class="pl-c"><span class="pl-c">//</span> After</span>
type Props <span class="pl-k">=</span> {
  propA<span class="pl-k">:</span> <span class="pl-c1">X</span>
} <span class="pl-k">&amp;</span> {
  propB<span class="pl-k">:</span> <span class="pl-c1">X</span>
} <span class="pl-k">&amp;</span> {
  propC<span class="pl-k">:</span> <span class="pl-c1">X</span>
} <span class="pl-k">&amp;</span> {
  propD<span class="pl-k">:</span> <span class="pl-c1">X</span>
};</pre></div>
<h3>Keep parens around TSAsExpression in ConditionalExpression (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3053" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="266402555" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3053">#3053</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>We missed a case where we need to keep the parenthesis with TypeScript's <code>as</code> assertions. This is now fixed.</p>
<div class="highlight highlight-source-ts"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
<span class="pl-c"></span><span class="pl-smi">aValue</span> <span class="pl-k">as</span> <span class="pl-c1">boolean</span> ? <span class="pl-c1">0</span> : <span class="pl-k">-</span><span class="pl-c1">1</span>;

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-c"></span>(<span class="pl-smi">aValue</span> <span class="pl-k">as</span> <span class="pl-c1">boolean</span>) <span class="pl-k">?</span> <span class="pl-c1">0</span> <span class="pl-k">:</span> <span class="pl-k">-</span><span class="pl-c1">1</span>;</pre></div>
<h2>JSX</h2>
<h3>Collapse multiple JSX whitespaces (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2973" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="262564212" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2973">#2973</a>) by <a href="https://urls.greenkeeper.io/karl" class="user-mention">@karl</a></h3>
<p>This fixes up the issue where JSX formatting occasionally needed to be run twice to become stable. This occurred when you had multiple JSX whitespace elements or JSX whitespace followed by a space.</p>
<div class="highlight highlight-source-js-jsx"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
&lt;<span class="pl-ent">div</span>&gt;
    <span class="pl-pse">{</span><span class="pl-s1"><span class="pl-s"><span class="pl-pds">"</span> <span class="pl-pds">"</span></span></span><span class="pl-pse">}</span> &lt;<span class="pl-ent"><span class="pl-c1">Badge</span></span> <span class="pl-e">src</span><span class="pl-k">=</span><span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">notificationIconPng</span></span><span class="pl-pse">}</span> /&gt;
&lt;/<span class="pl-ent">div</span>&gt;;

<span class="pl-c"><span class="pl-c">//</span> After</span>
&lt;<span class="pl-ent">div</span>&gt;
  <span class="pl-pse">{</span><span class="pl-s1"><span class="pl-s"><span class="pl-pds">"</span> <span class="pl-pds">"</span></span></span><span class="pl-pse">}</span>
  &lt;<span class="pl-ent"><span class="pl-c1">Badge</span></span> <span class="pl-e">src</span><span class="pl-k">=</span><span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">notificationIconPng</span></span><span class="pl-pse">}</span> /&gt;
&lt;/<span class="pl-ent">div</span>&gt;</pre></div>
<h3>Don't print JSX bracket on same line when it has trailing comments (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3088" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267549517" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3088">#3088</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>This was an issue with the <code>--jsx-bracket-same-line</code> option. Turns out you can't <em>always</em> put the bracket on the same line...</p>
<div class="highlight highlight-source-js-jsx"><pre><span class="pl-c"><span class="pl-c">//</span> Input</span>
&lt;<span class="pl-ent">div</span>
<span class="pl-c">  <span class="pl-c">//</span> comment</span>
&gt;
  <span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">foo</span></span><span class="pl-pse">}</span>
&lt;/<span class="pl-ent">div</span>&gt;

<span class="pl-c"><span class="pl-c">//</span> Before</span>
&lt;<span class="pl-ent">div</span>&gt;
// comment
  <span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">foo</span></span><span class="pl-pse">}</span>
&lt;/<span class="pl-ent">div</span>&gt;;

<span class="pl-c"><span class="pl-c">//</span> After</span>
&lt;<span class="pl-ent">div</span>
<span class="pl-c"><span class="pl-c">//</span> comment</span>
&gt;
  <span class="pl-pse">{</span><span class="pl-s1"><span class="pl-smi">foo</span></span><span class="pl-pse">}</span>
&lt;/<span class="pl-ent">div</span>&gt;;</pre></div>
<h2>CSS</h2>
<h3>Preserve line breaks in grid declarations (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3133" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="270384528" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3133">#3133</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>Prettier will now preserve line breaks included in the source code when formatting the <code>grid</code> and <code>grid-template-*</code> rules, since those are important to keep in separate lines, but still applies the formatting like other rules (e.g., numbers and quotes).</p>
<div class="highlight highlight-source-css"><pre><span class="pl-c"><span class="pl-c">/*</span> Original Input <span class="pl-c">*/</span></span>
<span class="pl-ent">div</span> {
  <span class="pl-c1"><span class="pl-c1">grid</span></span>:
    [wide-start] <span class="pl-s"><span class="pl-pds">'</span>header header header<span class="pl-pds">'</span></span> <span class="pl-c1">200.000<span class="pl-k">px</span></span>
    [wide-end] <span class="pl-s"><span class="pl-pds">"</span>footer footer footer<span class="pl-pds">"</span></span> <span class="pl-c1">.50<span class="pl-k">fr</span></span>
    / <span class="pl-c1">auto</span> <span class="pl-c1">50.000<span class="pl-k">px</span></span> <span class="pl-c1">auto</span>;
}

<span class="pl-c"><span class="pl-c">/*</span> Before <span class="pl-c">*/</span></span>
<span class="pl-ent">div</span> {
  <span class="pl-c1"><span class="pl-c1">grid</span></span>: [wide-start] <span class="pl-s"><span class="pl-pds">"</span>header header header<span class="pl-pds">"</span></span> <span class="pl-c1">200<span class="pl-k">px</span></span> [wide-end]
    <span class="pl-s"><span class="pl-pds">"</span>footer footer footer<span class="pl-pds">"</span></span> <span class="pl-c1">0.5<span class="pl-k">fr</span></span> / <span class="pl-c1">auto</span> <span class="pl-c1">50<span class="pl-k">px</span></span> <span class="pl-c1">auto</span>;
}

<span class="pl-c"><span class="pl-c">/*</span> After <span class="pl-c">*/</span></span>
<span class="pl-ent">div</span> {
  <span class="pl-c1"><span class="pl-c1">grid</span></span>:
    [wide-start] <span class="pl-s"><span class="pl-pds">"</span>header header header<span class="pl-pds">"</span></span> <span class="pl-c1">200<span class="pl-k">px</span></span>
    [wide-end] <span class="pl-s"><span class="pl-pds">"</span>footer footer footer<span class="pl-pds">"</span></span> <span class="pl-c1">0.5<span class="pl-k">fr</span></span>
    / <span class="pl-c1">auto</span> <span class="pl-c1">50<span class="pl-k">px</span></span> <span class="pl-c1">auto</span>;
}</pre></div>
<h2>SCSS</h2>
<h3>Format SCSS maps like CSS rules (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3070" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267054763" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3070">#3070</a>) by <a href="https://urls.greenkeeper.io/asmockler" class="user-mention">@asmockler</a></h3>
<p>Turns out SCSS maps are much prettier when printed over multiple lines.</p>
<div class="highlight highlight-source-scss"><pre><span class="pl-c">// Before</span>
<span class="pl-smi">$map</span>: (color: <span class="pl-c1">#111111</span>, <span class="pl-c1">text</span><span class="pl-c1">-</span>shadow:<span class="pl-c1"> 1</span><span class="pl-k">px</span><span class="pl-c1"> 1</span><span class="pl-k">px</span><span class="pl-c1"> 0</span> <span class="pl-bu">salmon</span>)

// After
<span class="pl-smi">$map</span>: (
  color: <span class="pl-c1">#111111</span>,
  <span class="pl-c1">text</span><span class="pl-c1">-</span>shadow:<span class="pl-c1"> 1</span><span class="pl-k">px</span><span class="pl-c1"> 1</span><span class="pl-k">px</span><span class="pl-c1"> 0</span> <span class="pl-bu">salmon</span>
);</pre></div>
<h2>CSS-in-JS</h2>
<h3>Fix formatting styled(Foo).attrs(...)`` (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3073" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="267192603" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3073">#3073</a>) by <a href="https://urls.greenkeeper.io/existentialism" class="user-mention">@existentialism</a></h3>
<p>Prettier will now format the CSS in styled-components code that looks like this:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-en">styled</span>(Component).<span class="pl-en">attrs</span>({})<span class="pl-s"><span class="pl-pds">`</span></span>
<span class="pl-s">  color: red;</span>
<span class="pl-s"><span class="pl-pds">`</span></span>;</pre></div>
<h2>GraphQL</h2>
<h3>Prevent formatting GraphQL template literals with expressions (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2975" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="262809788" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2975">#2975</a>) by <a href="https://urls.greenkeeper.io/duailibe" class="user-mention">@duailibe</a></h3>
<p>Prettier doesn't support formatting JavaScript expressions in GraphQL. See <a href="https://urls.greenkeeper.io/prettier/prettier/issues/2640" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="251412470" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2640">#2640</a> for tracking. There was a bug where formatting an expression lead to invalid code, so we've completely disabled formatting GraphQL when it contains JavaScript expressions until we fully support it.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before</span>
(invalid code)

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-en">graphql</span>(schema, <span class="pl-s"><span class="pl-pds">`</span>{ query test { id }} <span class="pl-s1"><span class="pl-pse">${</span>fragment<span class="pl-pse">}</span></span><span class="pl-pds">`</span></span>)</pre></div>
<h2>CLI</h2>
<h3>Don't use ANSI codes if stdout isn't a TTY (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2903" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="260810621" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2903">#2903</a>) by <a href="https://urls.greenkeeper.io/narigo" class="user-mention">@Narigo</a></h3>
<p>Previously, piping the output of <code>--list-different</code> to other tools was troublesome due to the ANSI color codes we use to show whether a file was modified or not. This PR disables the use of color when Prettier is piped to a different process.</p>
<h2>Configuration</h2>
<h3>Use relative paths with CLI (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/2969" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="262449905" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/2969">#2969</a>) by <a href="https://urls.greenkeeper.io/ahmedelgabri" class="user-mention">@ahmedelgabri</a></h3>
<p>This fixes a bug where passing a path starting with <code>./</code> to the CLI wouldn't match patterns used in <code>.prettierignore</code>.</p>
<pre><code># .prettierignore
path/to/*.js
</code></pre>
<p>After this fix, no files will be written to when executing:</p>
<div class="highlight highlight-source-shell"><pre>$ prettier --write ./path/to/<span class="pl-k">*</span>.js</pre></div>
<h3>Resolve file paths relative to config file (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3037" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="265550594" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3037">#3037</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>This fixes an issue where <code>.prettierrc</code> overrides, under certain conditions, were not being respected for absolute paths with the <code>resolveConfig</code> API.</p>
<h2>Core</h2>
<h3>Respect CJK width and Combined Characters (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3003" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="264227112" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3003">#3003</a>,  <a href="https://urls.greenkeeper.io/prettier/prettier/pull/3015" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="264803229" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3015">#3015</a>) by <a href="https://urls.greenkeeper.io/ikatyang" class="user-mention">@ikatyang</a></h3>
<p>Chinese, Japanese and Korean characters are now considered two characters wide.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Before (exceeds print width when CJK characters are 2x monospace chars)</span>
<span class="pl-k">const</span> <span class="pl-c1">x</span> <span class="pl-k">=</span> [<span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>];

<span class="pl-c"><span class="pl-c">//</span> After</span>
<span class="pl-k">const</span> <span class="pl-c1">x</span> <span class="pl-k">=</span> [
  <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>,
   <span class="pl-c"><span class="pl-c">//</span> ...</span>
  <span class="pl-s"><span class="pl-pds">"</span>中文<span class="pl-pds">"</span></span>
];</pre></div>
<p><a href="https://urls.greenkeeper.io/prettier/prettier/pull/3015" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="264803229" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3015">#3015</a> also ensures that combining characters (e.g. <code>Á</code>) are counted as one character.</p>
<h2>Editor Support</h2>
<h3>Implement getSupportInfo() and use it for inference (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3033" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="265494522" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3033">#3033</a>) by <a href="https://urls.greenkeeper.io/azz" class="user-mention">@azz</a></h3>
<p>We've added a new function to the API (<code>prettier.getSupportInfo([version])</code>), and the CLI <code>--support-info</code>. This can be used to interrogate Prettier to find out which languages the current version, or an older version, supports. It also provides useful information such as CodeMirror IDs, tmScopes, etc, which can be used to automate some of the work done with lookup tables in text editor integrations.</p>
<p>Internally, we use this information to drive which extensions trigger which parsers, and support some common files that don't have extensions, like <code>.prettierrc</code>, <code>Jakefile</code>, etc.</p>
<div class="highlight highlight-source-shell"><pre><span class="pl-c"><span class="pl-c">#</span> prettier knows that this file is JSON now.</span>
$ prettier --write .prettierrc</pre></div>
<h3>Split source elements relative to their language. (<a href="https://urls.greenkeeper.io/prettier/prettier/pull/3069" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="266872265" data-permission-text="Issue title is private" data-url="https://github.com/prettier/prettier/issues/3069">#3069</a>) by <a href="https://urls.greenkeeper.io/cigit" class="user-mention">@CiGit</a></h3>
<p>This fixes an issue in editors that support range formatting, where formatting an object would cause Prettier to crash.</p>
<hr>
<h1>Thanks! <g-emoji alias="heart" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/2764.png" ios-version="6.0">❤️</g-emoji></h1>
<p>Thanks to everyone who contributed to this release, as well as those who raised issues! Prettier has become a highly stable piece of software that a large amount of people trust with their code. We take that trust seriously, and fix rare issues that break code with the highest priority. We can't fix these issues if we don't know about them, so never be afraid to <a href="https://urls.greenkeeper.io/prettier/prettier/issues/new">create an issue</a>!</p>
</details>



<details>
<summary>FAQ and help</summary>

There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those dont help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).
</details>


---


Your [Greenkeeper](https://greenkeeper.io) Bot :palm_tree:

CONTENT_DOWNLOAD_MISMATCH on prematurely closed streams

Issue

When you use the bucket.file(...).createReadStream() and pipe it to a target target stream, and that target stream is ended/closed before the Google Cloud Storage client is finished reading the remote file, the validation fails because it tries to compare the partially received data with the remote hash.

I've created a repository containing a simplified example of the problem. In the real-world, we experienced this problem when an HTTP server behind a reverse proxy was piping from GCS to the HTTP response, and the upstream proxy closed the socket.

Environment details

  • OS: Ubuntu Linux 16.04
  • Node.js version: 8.7.0
  • npm version: 5.4.2
  • @google-cloud/storage version: 1.4.0

Steps to reproduce

  1. git clone [email protected]:rexxars/gcs-premature-eos-error.git
  2. cd gcs-premature-eos-error
  3. npm install
  4. Define the following environment variables (alternatively, modify test.js directly):
    • GCS_KEY_PATH - Path to a Google Cloud key file with access to a bucket
    • GCS_BUCKET - Name of Google Cloud Storage bucket to fetch from
    • GCS_FILE_PATH - Path to a file inside of the bucket
  5. npm test

After 60 seconds, the script will exit with the following error:

Error: The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.
    at onComplete (.../node_modules/@google-cloud/storage/src/file.js:638:29)
    at .../node_modules/@google-cloud/storage/src/bucket.js:1439:7
    at Object.handleResp (.../node_modules/@google-cloud/common/src/util.js:135:3)
    at .../node_modules/@google-cloud/common/src/util.js:465:12
    at Request.onResponse [as _callback] (.../node_modules/retry-request/index.js:179:7)
    at Request.self.callback (.../node_modules/request/request.js:186:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (.../node_modules/request/request.js:1163:10)
    at emitOne (events.js:115:13)

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Smart Start Resumable Uploads

Some environments don't have writable $HOME directories, which will return an error from gcs-resumable-upload. We should confirm we can write to the directory before attempting a resumable upload.

Here are the ideal scenarios:

file.createWriteStream()

No options.resumable argument supplied.

  • Can write to home directory? Start resumable upload.
  • Cannot write to home directory? Fall back to simple upload.

We can explain in the docs we will attempt a resumable upload, but won't guarantee it. In either case, the user does not know which was used.

file.createWriteStream({ resumable: true })

Resumable upload was explicitly requested.

  • Can write to home directory? Start resumable upload.
  • Cannot write to home directory? Emit an error, close the stream.

file.createWriteStream({ resumable: false })

Resumable upload was explicitly denied.

  • Do not attempt to write to home directory.
  • Start simple upload.

An in-range update of @google-cloud/nodejs-repo-tools is breaking the build 🚨

Version 2.1.2 of @google-cloud/nodejs-repo-tools was just published.

Branch Build failing 🚨
Dependency @google-cloud/nodejs-repo-tools
Current Version 2.1.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@google-cloud/nodejs-repo-tools is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch Waiting for AppVeyor build to complete Details
  • ci/circleci: node6 Your tests passed on CircleCI! Details
  • ci/circleci: node8 Your tests passed on CircleCI! Details
  • ci/circleci: node7 Your tests passed on CircleCI! Details
  • ci/circleci: node4 Your tests passed on CircleCI! Details
  • ci/circleci: docs Your tests passed on CircleCI! Details
  • ci/circleci: lint Your tests failed on CircleCI Details

Commits

The new version differs by 2 commits.

  • 8fec7e1 2.1.2
  • e9461eb Add 'yaml' option to "repo-tools test deploy" (#75)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Storage.createBucket fails without callback

The docs for createBucket indicate that it supports invocation without a callback and should return a promise:

//-
// If the callback is omitted, we'll return a Promise.
//-
storage.createBucket('new-bucket').then(function(data) {
  var bucket = data[0];
  var apiResponse = data[1];
});

In reality, this fails with:

TypeError: callback is not a function

Looking at the source, it seems to do some weird things with treating metadata as a function:

if (!callback) {
    callback = metadata;
    metadata = {};
}

It seems this will either result in callback being undefined (as metadata is also optional), or callback will be an object but still not a function.

There doesn't appear to be any path in the API callback to return a promise

Storage: lots of "socket hang up" errors

From @ovaris on September 21, 2017 8:31

Environment details

  • OS:
  • Node.js version: 8.5.0
  • npm version: 5.3.0
  • google-cloud-node/storage version: 1.2.1

I have a utlity nodejs script that checks existence of few thousands of files in cloud storage.
I run script locally, so not in Cloud environment.
I'm executing those checks (bucket.file(fileName).exists()) in batch of 20, so not all checks are fired concurrently.
I'm seeing lots of these errors when trying to run script:

{ Error: socket hang up
    at TLSSocket.onHangUp (_tls_wrap.js:1140:19)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:110:20)
    at TLSSocket.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  code: 'ECONNRESET',
  path: null,
  host: 'accounts.google.com',
  port: 443,
  localAddress: undefined }

and these:

{ Error: read ECONNRESET
    at _errnoException (util.js:1026:11)
    at TLSWrap.onread (net.js:606:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

aaand these:

{ Error: socket hang up
    at createHangUpError (_http_client.js:345:15)
    at TLSSocket.socketOnEnd (_http_client.js:437:23)
    at emitNone (events.js:110:20)
    at TLSSocket.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }

I have added this fix (suggested here: googleapis/google-cloud-node#2254):

const gcs = storage();
//https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2254
gcs.interceptors.push({
    request: function(reqOpts) {
        reqOpts.forever = false;
        return reqOpts
    }
});

I have tried to reduce the check batch size, but it didn't have any effect.

Copied from original issue: googleapis/google-cloud-node#2623

Storage: When moving a file, allow keeping old ACL

From @SimenB on May 3, 2017 13:59

Environment details

  • OS: macOS
  • Node.js version: 6.10.2
  • npm version: yarn 0.23.3
  • google-cloud-node version: @google-cloud/[email protected]

Steps to reproduce

  1. require @google-cloud/storage
  2. Instantiate it, and get a bucket
  3. call const file = await bucket.upload(filePath, { public: true })
  4. Verify file is publicly available from https://storage.googleapis.com/
  5. call file.move(somewhere)
  6. Try to access file from https://storage.googleapis.com/, get 403

What I want is either:

Copied from original issue: googleapis/google-cloud-node#2274

feature request: allow stream in File.save

To avoid some boilerplate code with streams it would be nice to be able to pass a stream to File.save

Example

const read = fs.createReadStream('./somefile.bin');
const file = bucket.file(`test.bin`);
await file.save(read);
// do other stuff

This would be very useful when working with promises.

storage - readStream hangs on long running time pipe

From @tomgrossman on August 26, 2017 9:49

Environment details

  • OS: Ubuntu 16.04
  • Node.js version: 6.11.2
  • npm version: 3.10.10
  • google-cloud-node version: @google-cloud/[email protected]

Some more details:
The file size I'm reproducing the issue on is ~2.3 gb.
The issue is happening only when using pipe and only when the download speed is below 5 mb\s.
When the download speed is faster or when using .on('data', (data) => res.write(data)), there is no problem.

Steps to reproduce

  1. require @google-cloud/storage
  2. use the following route function, where bucketFile is a pure file instance from the storage lib:
function DownloadOva (req, res) {
    console.log(new Date() + ' start');

    res.on('finish', function () {
        console.log(new Date() + ' finish');
    });

    let bucketFile = OvaFileHelpers.GetBucketFile('agent_ova/agent.ova');
    bucketFile.createReadStream({validation: false})
        .on('error', (err) => {
            console.log(new Date() + ' error: ' + err.stack);
        })
        .on('response', (streamResponse) => {
            console.log(new Date() + ' streamResponse');
            res.setHeader('Content-Length', streamResponse.headers['content-length']);
            res.setHeader('Content-Type', streamResponse.headers['content-type']);
            res.setHeader('Content-disposition', 'attachment; filename="agent_download.ova"');
        })
        .on('end', () => {
            console.log(new Date() + ' end');
            res.end();

            return true;
        })
        // .on('data', (data) => {
        //     Response.write(data);
        // })
        .pipe(res);
}
  1. limit the download speed in chrome using the throttling option in the network developer tools to 5000 kb/s
  2. call the route

Expected results:
all console logs outputs should be written to console.
Actual results:
The file is downloaded successfully
the 'end' and 'finish' events are never called (no console log outputs and doesn't get into the breakpoint).
Can't call the route again until restarting the application

more details:
When the download speed is not limited, it works fine (on high speed connection). but some users with low speed connections, faced this issue (that's why I reproduced this issue).
When using the commented .on('data' ... and commenting out the pipe, it also works fine also on slow download.

It seems that when the pipe takes too long (seems like 3-4 minutes), it looses all the event listening functions and gets hangs even though the download finish successfully on the client side.

Thanks!

Copied from original issue: googleapis/google-cloud-node#2569

[Request] Verify User Project methods comments are not ambiguous

General Request:

Verify that the comments are clear for methods which accept User Project with and without Requester Pays.

Here's a distinction between Requester Pays and User Project:
User Project: Is a request metadata field that is used to assign Storage operational costs to a specified project.

Requester Pays: Is a bucket-level metadata field that is used to enforce the use of the User Project metadata field to assign operational costs when an operation is made on a Bucket and its objects.

docs: explain that the IAM scope is required

Environment details

  • OS: GKE cos
  • Node.js version: 8.6
  • npm version: 5.0.3
  • @google-cloud/storage version: 1.5.1

Steps to reproduce

I'm trying to generate a signed url from within my node app running on a GKE cluster; I'm getting the error Request had insufficient authentication scopes. I'm wondering which scope(s) are necessary to enable signing; my cluster has "full" permissions for storage.

Many thanks for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.