Skip to content

Commit

Permalink
chore: merge liferay-npm-tools history into projects/
Browse files Browse the repository at this point in the history
This is a "subtree merge" to preserve the entire history and tags of
the liferay-npm-tools repo. This one is a bit simpler than the merge
of eslint-config-liferay which I did in 811c279. That
one required us to rewrite the tags because they weren't namespaced
appropriately for use in a monorepo (ie. they were of the form "v1.0.0"
instead of "eslint-config-liferay/v1.0.0). liferay-npm-tools, however,
already uses namespaced tags, so the import is more straightforward:

    # Fetch it.
    git remote add -f liferay-npm-tools /~https://github.com/liferay/liferay-npm-tools

    # Inspect the tags to make sure everything is correctly namespaced.
    git tag -l

    # Do the subtree merge.
    git merge -s ours --no-commit --allow-unrelated-histories liferay-npm-tools/master
    git read-tree --prefix=projects/npm-tools -u liferay-npm-tools/master
    git commit -m "chore: merge liferay-npm-tools history into projects/"

    # Check the result has the right shape and tags.
    git log --oneline --decorate --graph --all

    # Amend the commit message (you're reading it) to explain what you did.
    git commit --amend
  • Loading branch information
wincent committed Sep 23, 2020
2 parents b2a06b1 + e5fffe8 commit df7bbfe
Show file tree
Hide file tree
Showing 237 changed files with 70,943 additions and 0 deletions.
2 changes: 2 additions & 0 deletions projects/npm-tools/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
copyright.js
27 changes: 27 additions & 0 deletions projects/npm-tools/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

const path = require('path');

module.exports = {
env: {
browser: true,
jest: true,
node: true,
},
extends: 'liferay',
parserOptions: {
ecmaVersion: 2018,
},
rules: {
'no-for-of-loops/no-for-of-loops': 'off',
'notice/notice': [
'error',
{
templateFile: path.join(__dirname, 'copyright.js'),
},
],
},
};
6 changes: 6 additions & 0 deletions projects/npm-tools/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Don't let Git transform line-endings to CRLF on Windows, because that
# would break the snapshots.
*.js text eol=lf
*.jsp text eol=lf
*.jspf text eol=lf
*.js.snap text eol=lf
13 changes: 13 additions & 0 deletions projects/npm-tools/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# Configuration for the GitHub's Dependabot.
#
# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- directory: "/"
open-pull-requests-limit: 1
package-ecosystem: "npm"
rebase-strategy: "disabled"
schedule:
interval: "weekly"
7 changes: 7 additions & 0 deletions projects/npm-tools/.github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Configuration for the Semantic Pull Request bot.
# /~https://github.com/probot/semantic-pull-requests

allowMergeCommits: true

titleAndCommits: true
1 change: 1 addition & 0 deletions projects/npm-tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions projects/npm-tools/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copyright.js
12 changes: 12 additions & 0 deletions projects/npm-tools/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

module.exports = {
bracketSpacing: false,
singleQuote: true,
tabWidth: 4,
trailingComma: 'es5',
useTabs: true,
};
18 changes: 18 additions & 0 deletions projects/npm-tools/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
before_install: ./.travis/before_install.sh

env:
global:
- YARN_GPG=no

install: ./.travis/install.sh

language: node_js

node_js:
- '10'

os:
- linux
- windows

script: ./.travis/script.sh
28 changes: 28 additions & 0 deletions projects/npm-tools/.travis/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

mkdir -p "$HOME/.yarn/bin"
curl -L -o "$HOME/.yarn/bin/yarn" /~https://github.com/yarnpkg/yarn/releases/download/v1.15.2/yarn-1.15.2.js
chmod +x "$HOME/.yarn/bin/yarn"
export PATH="$HOME/.yarn/bin:$PATH"

if [ "$OS" = "Windows_NT" ]; then
# Speed up Yarn install on Windows.
#
# See: https://travis-ci.community/t/yarn-network-troubles/333/6

export NODEPATH=$(where.exe node.exe)
export PROJECTDIR=$(pwd)
export YARNCACHE=$(yarn cache dir)
export TEMPDIR=$LOCALAPPDATA\\Temp

powershell Add-MpPreference -ExclusionProcess ${NODEPATH}
powershell Add-MpPreference -ExclusionPath ${YARNCACHE}
powershell Add-MpPreference -ExclusionPath ${PROJECTDIR}
powershell Add-MpPreference -ExclusionPath ${TEMPDIR}

powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableArchiveScanning \$true'"

powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableBehaviorMonitoring \$true'"

powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableRealtimeMonitoring \$true'"
fi
3 changes: 3 additions & 0 deletions projects/npm-tools/.travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

yarn
20 changes: 20 additions & 0 deletions projects/npm-tools/.travis/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ "$OS" = "Windows_NT" ]; then
# On Windows, just the tests, not the format checks or lints, because
# `prettier` is going to freak out about nothing matching the globs on
# Windows.
#
# Note that we can't run `yarn test` directly because on Windows:
#
# - `yarn` is a .bat script.
# - `yarn test` invokes `yarn jest`.
# - .bat scripts don't actually wait for child .bat scripts to return
# (/~https://github.com/npm/npm/issues/2938#issuecomment-11337463).
# - This causes our script here to return early, and then the whole run times
# out after 10 minutes...
#
node node_modules/jest-cli/bin/jest.js
else
yarn format:check && yarn lint && yarn test
fi
134 changes: 134 additions & 0 deletions projects/npm-tools/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Release process

## Contents

- [Normal releases](#normal-releases)
- [Publishing manually](#publishing-manually)
- [Publishing a preview release](#publishing-a-preview-release)

## Normal releases

> **Note:** liferay-npm-scripts can be published independently, but if you update the preset, or the reporter, you need to update liferay-npm-scripts as well, because it depends on the others. When doing this, it is important to publish the packages in order; with liferay-npm-scripts always going last.
> To publish a new version of a package:
```sh
# Make sure the local "master" branch is up-to-date:
git checkout master
git pull --ff-only upstream master

# See all checks pass locally:
yarn ci

# If any checks fail, fix them, submit a PR, and when it is merged,
# start again. Otherwise...

# Change to the directory of the package you wish to publish:
cd packages/liferay-npm-scripts

# Update the changelog:
npx liferay-changelog-generator --version=29.0.1

# Review and stage the generated changes:
git add -p

# Update the version number:
yarn version --minor # or --major, or --patch
```

Running `yarn version` has the following effects:

- The "preversion" script will run, which effectively runs `yarn ci` again.
- The "package.json" gets updated with the new version number.
- A tagged commit is created, including the changes to the changelog that you previously staged.
- The "postversion" script will run, which automatically does `git push` and performs a `yarn publish`, prompting for confirmation along the way.

Copy the relevant section from the changelog to the corresponding entry on the [releases page](/~https://github.com/liferay/liferay-npm-tools/releases).

After the release, you can confirm that the packages are correctly listed in the NPM registry:

- https://www.npmjs.com/package/liferay-changelog-generator
- https://www.npmjs.com/package/liferay-jest-junit-reporter
- https://www.npmjs.com/package/liferay-js-insights
- https://www.npmjs.com/package/liferay-js-publish
- https://www.npmjs.com/package/liferay-npm-bundler-preset-liferay-dev
- https://www.npmjs.com/package/liferay-npm-scripts

## Publishing manually

If the "postversion" script cannot complete for any reason, it will print a message saying why, and advising you:

> Please try publishing manually as per the CONTRIBUTING.md.
Here are the steps that the "postversion" script is actually trying to perform:

```sh
# Check you are on the master branch
git rev-parse --abbrev-ref HEAD

# Check worktree is clean
git diff --quiet

# Update upstream "master"
git push upstream master

# Merge "master" into "stable"
git checkout stable
git merge --ff-only master

# Update upstream "stable"
git push upstream stable --follow-tags

# Return to the "master" branch
git checkout master

# Actually publish
yarn publish
```

## Publishing a preview release

Sometimes, it can be useful to publish a preview release for testing purposes prior to a broader roll-out, but it is a somewhat manual process.

As an example, this is the procedure followed to produce [the v9.5.0-beta.1 release](https://www.npmjs.com/package/liferay-npm-scripts/v/9.5.0-beta.1) of liferay-npm-scripts:

```sh
# Check out a branch for the release
git checkout -b some/branch-name

# Check worktree is clean
git diff --quiet

# See CI checks pass locally
yarn ci

# Move into the package's directory
cd packages/liferay-npm-scripts

# Update the changelog.
npx liferay-changelog-generator --version=$PACKAGE_NAME/v9.5.0-beta.1

# Bump to the prerelease version number
yarn version --new-version 9.5.0-beta.1

# Because you are not on the "master" branch,
# the automated release script will refuse to run;
# proceed manually

# Inspect what you are going to publish
git show

# Push it
git push upstream --dry-run
git push upstream

# Push the tag
git push upstream --tags --dry-run
git push upstream --tags

# Actually publish: note the --tag switch
yarn publish --tag beta
```

For bonus points, create a draft PR like [this one](/~https://github.com/liferay/liferay-npm-tools/pull/201) so that others have visibility into what you are doing. After the release is done you should feel free to close the PR and delete the temporary branch that you pushed (but keep the tag in case anybody ever wants to look up the source that was published to NPM).

Finally, visit the versions tab on [the NPM registry page](https://www.npmjs.com/package/liferay-npm-scripts) to confirm that your release is visible and is appropriately tagged as "beta" (not "latest").
13 changes: 13 additions & 0 deletions projects/npm-tools/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 3-Clause BSD License

Copyright (c) 2019, Liferay Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 changes: 13 additions & 0 deletions projects/npm-tools/LICENSES/BSD-3-Clause.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 3-Clause BSD License

Copyright (c) 2019, Liferay Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 changes: 13 additions & 0 deletions projects/npm-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# liferay-npm-tools

## Setup

1. Install NodeJS >= [v10.15.1](http://nodejs.org/dist/v10.15.1/), if you don't have it yet.

(At the time of writing, v10.15.1 is the version used by [liferay-portal](/~https://github.com/liferay/liferay-portal), and code in this project is written using "modern JS" syntax and features — without transpilation and executed directly.)

2. Run yarn to install local dependencies and link packages together:

```sh
yarn
```
5 changes: 5 additions & 0 deletions projects/npm-tools/copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* SPDX-FileCopyrightText: © <%= YEAR %> Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: BSD-3-Clause
*/

29 changes: 29 additions & 0 deletions projects/npm-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"devDependencies": {
"eslint": "6.8.0",
"eslint-config-liferay": "21.1.0",
"prettier": "2.0.5"
},
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/packages/liferay-npm-scripts/support/jest/matchers.js"
],
"testMatch": [
"**/test/**/*.js"
]
},
"private": true,
"scripts": {
"ci": "yarn format:check && yarn lint && yarn test",
"format": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\"",
"format:check": "prettier --list-different \"**/*.js\" \"**/*.json\" \"**/*.md\"",
"lint": "eslint \".*.js\" \"**/*.js\"",
"lint:fix": "eslint --fix \".*.js\" \"**/*.js\"",
"preversion": "echo Cannot version top-level private package; false",
"test": "jest"
},
"workspaces": [
"packages/*"
],
"version": "0.1.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make `yarn version` produce the right commit message and tag for this package.
version-tag-prefix "liferay-changelog-generator/v"
version-git-message "chore: prepare liferay-changelog-generator/v%s"
Loading

0 comments on commit df7bbfe

Please sign in to comment.