Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .npmignore to create a leaner package #469

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Jun 7, 2018

Adds an .npmignore file to the project so that the final package sent
to NPM is lighter. Tests, examples, and other resources are stripped out
(it's easy to link back to this repository to refer to these if needed).

I've written this is in an "inverted" style so that only by default
everything is blacklisted, and we add back in the files and folders that
we know we'll want.

I verified that this does the right thing by using npm pack. Before
the addition of .npmignore:

$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    README.md       examples/       package.json
LICENSE         VERSION         lib/            test/

package//examples:
webhook-signing/

package//examples/webhook-signing:
express.js      package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js

package//test:
Error.spec.js           flows.spec.js           stripe.spec.js
StripeResource.spec.js  mocha.opts              testUtils.js
Webhook.spec.js         resources/              utils.spec.js

package//test/resources:
Account.spec.js                 EphemeralKeys.spec.js           Recipients.spec.js
ApplePayDomains.spec.js         Events.spec.js                  Refunds.spec.js
ApplicationFeeRefunds.spec.js   ExchangeRates.spec.js           SKUs.spec.js
ApplicationFees.spec.js         FileUploads.spec.js             Sources.spec.js
Balance.spec.js                 InvoiceItems.spec.js            SubscriptionItems.spec.js
BitcoinReceivers.spec.js        Invoices.spec.js                Subscriptions.spec.js
ChargeRefunds.spec.js           IssuerFraudRecords.spec.js      ThreeDSecure.spec.js
Charges.spec.js                 LoginLinks.spec.js              Tokens.spec.js
CountrySpecs.spec.js            OrderReturns.spec.js            Topups.spec.js
Coupons.spec.js                 Orders.spec.js                  TransferReversals.spec.js
CustomerCards.spec.js           Payouts.spec.js                 Transfers.spec.js
CustomerSubscriptions.spec.js   Plans.spec.js                   UsageRecords.spec.js
Customers.spec.js               Products.spec.js                data/
Disputes.spec.js                RecipientCards.spec.js

package//test/resources/data:
minimal.pdf

And after:

$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    LICENSE         README.md       VERSION         lib/            package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js

Fixes #468.

r? @jlomas-stripe Mind taking a look at this one? Thanks!

Adds an `.npmignore` file to the project so that the final package sent
to NPM is lighter. Tests, examples, and other resources are stripped out
(it's easy to link back to this repository to refer to these if needed).

I've written this is in an "inverted" style so that only by default
everything is blacklisted, and we add back in the files and folders that
we know we'll want.

I verified that this does the right thing by using `npm pack`. Before
the addition of `.npmignore`:

``` sh
$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    README.md       examples/       package.json
LICENSE         VERSION         lib/            test/

package//examples:
webhook-signing/

package//examples/webhook-signing:
express.js      package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js

package//test:
Error.spec.js           flows.spec.js           stripe.spec.js
StripeResource.spec.js  mocha.opts              testUtils.js
Webhook.spec.js         resources/              utils.spec.js

package//test/resources:
Account.spec.js                 EphemeralKeys.spec.js           Recipients.spec.js
ApplePayDomains.spec.js         Events.spec.js                  Refunds.spec.js
ApplicationFeeRefunds.spec.js   ExchangeRates.spec.js           SKUs.spec.js
ApplicationFees.spec.js         FileUploads.spec.js             Sources.spec.js
Balance.spec.js                 InvoiceItems.spec.js            SubscriptionItems.spec.js
BitcoinReceivers.spec.js        Invoices.spec.js                Subscriptions.spec.js
ChargeRefunds.spec.js           IssuerFraudRecords.spec.js      ThreeDSecure.spec.js
Charges.spec.js                 LoginLinks.spec.js              Tokens.spec.js
CountrySpecs.spec.js            OrderReturns.spec.js            Topups.spec.js
Coupons.spec.js                 Orders.spec.js                  TransferReversals.spec.js
CustomerCards.spec.js           Payouts.spec.js                 Transfers.spec.js
CustomerSubscriptions.spec.js   Plans.spec.js                   UsageRecords.spec.js
Customers.spec.js               Products.spec.js                data/
Disputes.spec.js                RecipientCards.spec.js

package//test/resources/data:
minimal.pdf
```

And after:

``` sh
$ npm pack && tar -zxf stripe*.tgz && ls -R package/
stripe-6.1.0.tgz
CHANGELOG.md    LICENSE         README.md       VERSION         lib/            package.json

package//lib:
Error.js                        StripeMethod.js                 resources/
MultipartDataGenerator.js       StripeResource.js               stripe.js
StripeMethod.basic.js           Webhooks.js                     utils.js

package//lib/resources:
Accounts.js                     EphemeralKeys.js                Recipients.js
ApplePayDomains.js              Events.js                       Refunds.js
ApplicationFeeRefunds.js        ExchangeRates.js                SKUs.js
ApplicationFees.js              FileUploads.js                  Sources.js
Balance.js                      InvoiceItems.js                 SubscriptionItems.js
BitcoinReceivers.js             Invoices.js                     Subscriptions.js
ChargeRefunds.js                IssuerFraudRecords.js           ThreeDSecure.js
Charges.js                      LoginLinks.js                   Tokens.js
CountrySpecs.js                 OrderReturns.js                 Topups.js
Coupons.js                      Orders.js                       TransferReversals.js
CustomerCards.js                Payouts.js                      Transfers.js
CustomerSubscriptions.js        Plans.js                        UsageRecords.js
Customers.js                    Products.js
Disputes.js                     RecipientCards.js
```

Fixes #468.
@jlomas-stripe
Copy link
Contributor

jlomas-stripe commented Jun 7, 2018

The diff on those two seem to imply you're only pulling/excluding non-lib stuff:

3,10c3
< CHANGELOG.md    README.md       examples/       package.json
< LICENSE         VERSION         lib/            test/
<
< package//examples:
< webhook-signing/
<
< package//examples/webhook-signing:
< express.js      package.json
---
> CHANGELOG.md    LICENSE         README.md       VERSION         lib/            package.json
32,55d24
<
< package//test:
< Error.spec.js           flows.spec.js           stripe.spec.js
< StripeResource.spec.js  mocha.opts              testUtils.js
< Webhook.spec.js         resources/              utils.spec.js
<
< package//test/resources:
< Account.spec.js                 EphemeralKeys.spec.js           Recipients.spec.js
< ApplePayDomains.spec.js         Events.spec.js                  Refunds.spec.js
< ApplicationFeeRefunds.spec.js   ExchangeRates.spec.js           SKUs.spec.js
< ApplicationFees.spec.js         FileUploads.spec.js             Sources.spec.js
< Balance.spec.js                 InvoiceItems.spec.js            SubscriptionItems.spec.js
< BitcoinReceivers.spec.js        Invoices.spec.js                Subscriptions.spec.js
< ChargeRefunds.spec.js           IssuerFraudRecords.spec.js      ThreeDSecure.spec.js
< Charges.spec.js                 LoginLinks.spec.js              Tokens.spec.js
< CountrySpecs.spec.js            OrderReturns.spec.js            Topups.spec.js
< Coupons.spec.js                 Orders.spec.js                  TransferReversals.spec.js
< CustomerCards.spec.js           Payouts.spec.js                 Transfers.spec.js
< CustomerSubscriptions.spec.js   Plans.spec.js                   UsageRecords.spec.js
< Customers.spec.js               Products.spec.js                data/
< Disputes.spec.js                RecipientCards.spec.js
<
< package//test/resources/data:
< minimal.pdf

So I'd say this looks great. 👍

lgtm

@brandur-stripe
Copy link
Contributor

Thanks Jonathan! Pulling this in then.

@brandur-stripe brandur-stripe merged commit 4225807 into master Jun 7, 2018
@brandur-stripe brandur-stripe deleted the brandur-npmignore branch June 7, 2018 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants