Skip to content

Commit

Permalink
feat(new): initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Oct 14, 2018
0 parents commit 7868ff8
Show file tree
Hide file tree
Showing 33 changed files with 2,347 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/template
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@telus/eslint-config"
}
99 changes: 99 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
repository:
name: create-library
description: an opinionated npm package initializer
topics: init,npm,create,initializer
homepage: https://telus.com/digital
private: false
has_issues: true
has_wiki: false
has_downloads: false
has_projects: false
default_branch: master
allow_squash_merge: true
allow_merge_commit: false
allow_rebase_merge: true

teams:
- name: architecture-support
permission: admin

branches:
- name: master
protection:
required_pull_request_reviews:
required_approving_review_count: 1
dismiss_stale_reviews: true
require_code_owner_reviews: true
dismissal_restrictions:
users: []
teams:
- architecture-support

required_status_checks:
strict: true
contexts:
- 'ci/circleci: Build Error'

enforce_admins: true

restrictions:
users: []
teams:
- architecture-support

labels:
- name: bug
description: Something isn't working
color: EE3F46

- name: security
description: Security related topic
color: EE3F46

- name: chore
description: Changes that don't modify core files
color: FEF2C0

- name: discussion
description: A discussion thread
color: CC317C

- name: question
description: Generic question
color: CC317C

- name: enhancement
description: New feature or request
color: 5EBEFF

- name: optimizaiton
description: Performance or Code Optimization
color: 5EBEFF

- name: feature
description: New Feature
color: 91CA55

- name: in progress
description: Currently being worked on
color: FBCA04

- name: watchlist
description: Keep an eye on these
color: FBCA04

- name: invalid
description: Something doesn't seem right
color: D2DAE1

- name: wontfix
description: This will not be worked on
color: D2DAE1

- name: duplicate
description: This issue or pull request already exists
color: D2DAE1

- name: on hold
description: No work planned on this for now
color: D2DAE1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.log
/node_modules
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
access=public
3 changes: 3 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@telus/semantic-release-config"
}
5 changes: 5 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"@telus/remark-preset-lint-markdown"
]
}
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2018 TELUS Telecommunications Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# NPM Library Initializer

[![version][npm-image]][npm-url] [![Build Status][circle-image]][circle-url]

> an opinionated [npm package initializer][npm/init]
## Requirements

- `npm >= 6.x`
- `node >= 8.*`

## Usage

```bash
npm init @telus/library
```

## How does this work?

> _`npm init <initializer>` can be used to set up a new or existing npm package._
> _`initializer` in this case is an npm package named `create-<initializer>`, which will be installed by `npx`, and then have its main bin executed -- presumably creating or updating `package.json` and running any other initialization-related operations._
> _[&mdash; Source: `docs.npmjs.com`][npm/init]_
---
> Github: [@telus](https://github.com/telus) &bull;
> Twitter: [@telusdigital](https://twitter.com/telusdigital)
[circle-url]: https://circleci.com/gh/telus/create-library
[circle-image]: https://img.shields.io/circleci/project/github/telus/create-library/master.svg?style=for-the-badge&logo=circleci

[npm-url]: https://www.npmjs.com/package/@telus/create-library
[npm-image]: https://img.shields.io/npm/v/@telus/create-library.svg?style=for-the-badge&logo=npm

[npm/init]: https://docs.npmjs.com/cli/init#description
60 changes: 60 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2.1

executors:
app:
working_directory: ~/src

docker:
- image: telusops/build-essential:latest

commands:
persist:
steps:
- persist_to_workspace: { root: ~/src, paths: . }

attach:
steps:
- attach_workspace: { at: "." }

install:
steps:
- run:
name: Install dependencies
command: npm ci

jobs:
build:
executor: app
steps:
- checkout
- install
- persist

lint:
executor: app
steps:
- attach
- run: npm run lint

release:
executor: app
steps:
- attach
- run: npx semantic-release

workflows:
version: 2
run:
jobs:
- build:
context: npm-library

- lint:
requires: [ build ]

- release:
context: npm-library
requires: [ build, lint ]
filters:
branches:
only: master
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node
const yargs = require('yargs')
const template = require('./lib/template')

const builder = () => {
yargs.positional('path', {
describe: 'path to initialize project in',
type: 'string',
default: '.'
})
}

/* eslint-disable no-unused-expressions */
yargs
.command('$0 [path]', 'initiate a new project', builder, template)
.argv
21 changes: 21 additions & 0 deletions lib/licenses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const spdx = require('spdx-license-list/full')

const unlicensed = [{
name: 'UNLICENSED',
value: {
key: 'UNLICENSED',
name: 'UNLICENSED',
licenseText: '(c) Copyright <year> TELUS Telecommunications Inc. all rights reserved'
}
}]

const approved = ['ISC', 'AGPL-3.0-only', 'AGPL-3.0-or-later', 'Apache-2.0', 'GPL-3.0-only', 'GPL-3.0-or-later', 'LGPL-3.0-only', 'LGPL-3.0-or-later', 'MIT']

const opensource = Object.entries(spdx)
// only use approved licenses
.filter(([key]) => approved.includes(key))

// structure objects for use with `inquirer`
.map(([key, value]) => ({ name: value.name, value: Object.assign({ key }, value) }))

module.exports = unlicensed.concat(opensource)
64 changes: 64 additions & 0 deletions lib/questions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const inquirer = require('inquirer')
const name = require('validate-npm-package-name')

const licenses = require('./licenses')

// validation helpers
const validate = {
notEmpty: input => input && input.length > 0,
name: input => name(input).validForNewPackages
}

// the actual questions
module.exports = pkg => inquirer.prompt([
{
type: 'confirm',
name: 'oss',
message: 'is this an open source project?',
default: false
},
{
type: 'input',
name: 'title',
message: 'project title',
filter: input => input.trim(),
validate: validate.notEmpty
},
{
type: 'input',
name: 'description',
message: 'project description',
default: pkg.description,
filter: input => input.trim(),
validate: validate.notEmpty
},
{
type: 'input',
name: 'name',
message: 'package/repo name',
default: answers => (pkg.name ? pkg.name.replace(/@.+\//, '') : answers.title.toLowerCase().replace(/[\W_]+/g, '-')),
filter: input => input.trim(),
validate: validate.name
},
{
type: 'list',
name: 'license',
message: 'choose a license',
choices: licenses,
default: answers => pkg.license || (answers.oss ? 'MIT' : 'UNLICENSED')
},
{
type: 'input',
name: 'topics',
message: 'keywords to use (comma separated)',
default: pkg.keywords ? pkg.keywords.filter(keyword => keyword !== 'telus').join(', ') : null,
filter: input => input.trim().split(',').map(keyword => keyword.trim()),
validate: validate.notEmpty
},
{
type: 'input',
name: 'team',
message: 'maintainers (github team slug)',
validate: input => validate.notEmpty(input) && !/[^a-z-]/g.test(input)
}
])
Loading

0 comments on commit 7868ff8

Please sign in to comment.