Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Oct 7, 2024
0 parents commit d77361e
Show file tree
Hide file tree
Showing 142 changed files with 23,894 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:

jobs:
build:
name: Build [${{ matrix.framework }} - Node ${{ matrix.node-version }}]
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20.x]
framework: [react, vue, angular]

env:
CI: true
PROJECT_PATH: projects/node-${{ matrix.node-version }}/${{ matrix.framework }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
corepack enable
yarn install
- name: Build
run: |
yarn lint
yarn build
- name: Create project with framework ${{ matrix.framework }} Node-${{ matrix.node-version }}
env:
CARTO_AUTH_TOKEN: ${{ secrets.CARTO_AUTH_TOKEN }}
run: |
mkdir -p ${PROJECT_PATH}
node scripts/generate-ci-project.js ${{ matrix.framework }} ${PROJECT_PATH} ${CARTO_AUTH_TOKEN}
- name: Start project
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
run: |
set -x
cd ${PROJECT_PATH}
yarn
yarn dev --port 4000 &
sleep 30
curl http://localhost:4000/
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release

on:
push:
tags: ['*']

jobs:
release:
name: Release [Node.js ${{ matrix.node-version }}]
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20.x]

env:
CI: true

steps:
- name: Checkout
uses: actions/checkout@v4

##########################################################################
# Build
##########################################################################

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
corepack enable
yarn install
- name: Lint
run: yarn lint

- name: Build
run: yarn build

- name: Test
run: yarn test

##########################################################################
# Publish
##########################################################################

- name: Check tag format
id: check-tag-format
uses: nowsprinting/check-version-format-action@v4

- name: Exit on invalid tag format
if: '!steps.check-tag-format.outputs.is_valid'
run: echo "Tag must follow SemVer convention. Aborting." && exit 1

- name: Get release type
id: get-release-type
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const regex = /(alpha|beta)/
const refName = context.ref.replace('refs/tags/', '')
console.log(`Ref tag: ${refName}`)
const releaseTypeMatch = refName.match(regex)
if (!releaseTypeMatch) {
releaseType = 'latest'
} else {
releaseType = releaseTypeMatch[0]
}
console.log(`Release type: ${releaseType}`)
return releaseType
- name: Set version from tag to environment variable
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Ignore changes to .yarnrc.yml
run: git update-index --assume-unchanged .yarnrc.yml

- name: Configure yarn to publish packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }}
run: |
# Yarn config
yarn config set npmPublishRegistry "https://registry.npmjs.org/"
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}"
# Create .npmrc file
echo "@carto:registry=https://registry.npmjs.org/" > .npmrc
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
# Check configuration
npm config get registry
npm view @carto/create-common versions
- name: Publish package with Lerna
env:
RELEASE_TYPE: ${{ steps.get-release-type.outputs.result }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }}
run: |
set -x
yarn lerna publish from-git --yes --dist-tag ${RELEASE_TYPE} --loglevel verbose
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
node_modules

*.local
*.log

packages/*/dist

sandbox/*
!sandbox/.gitkeep

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Swap the comments on the following lines if you wish to use zero-installs
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
# Documentation here: https://yarnpkg.com/features/caching#zero-installs

#!.yarn/cache
.pnp.*
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
packages/*/build
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"singleQuote": true,
"arrowParens": "always"
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CHANGELOG

## 0.1

### 0.1.0

- Initial release
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing

_Contributions are subject to CARTO's [community contributions policy](https://carto.com/contributions/)._

## Local development requirements

- Yarn v4+
- Node.js v18+

## Quickstart

```bash
# install workspace dependencies
yarn

# build all templates
yarn build

# build and run local development servers for all templates
yarn dev
yarn dev:ssl # required for OAuth
```

After running `yarn dev`, all templates will begin running local development servers. Default configuration is found in a `.env` or `environment.ts` file in the template, with access to the default data sources. To test against other data sources, you may need to put another API key in the environment.

To run an individual template alone, run `yarn dev` in that template's subdirectory.

To test template instantiation locally, first run `yarn build`, and then run `node scripts/create.js path/to/target` from the template directory, and follow the prompts.

During local development, CSS styles are loaded from a shared `style.css` in the create-common module. When a template is instantiated, the dependency on create-common is removed and `style.css` is copied into the project for easier customization. All templates share a single global stylesheet.

## Releases

All packages are published together. To create a standard release:

1. Update changelog

2. Create a new version:

- Release: `yarn lerna publish [ patch | minor | major ] --force-publish "*"`
- Prerelease: `yarn lerna publish prerelease --dist-tag alpha --force-publish "*"`
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 CARTO

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.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# carto-app-templates

Templates for creating CARTO applications in React, Vue, and Angular.

## Quickstart

To create a new application, with CARTO, deck.gl, and your choice of web
frameworks:

```bash
# React
yarn create @carto/react path/to/my-project

# Vue
yarn create @carto/vue path/to/my-project

# Angular
yarn create @carto/angular path/to/my-project
```

At the prompts, provide a name for the project, and any other required
configuration details. A new CARTO application will be created in the
specified directory. To start development:

```bash
# open project directory
cd path/to/my-project

# install dependencies
yarn

# build and run local dev server
yarn dev

# build and run local dev server (OAuth)
yarn dev:ssl
```

## Versioning

Package versioning follows [Semantic Versioning 2.0.0](https://semver.org/).

## License

Provided as open source under [MIT License](./LICENSE.md).
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.1.1",
"packages": ["packages/*"],
"npmClient": "yarn"
}
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"private": true,
"packageManager": "[email protected]",
"workspaces": [
"packages/*"
],
"type": "module",
"scripts": {
"dev": "lerna run dev --parallel --stream",
"dev:ssl": "lerna run dev:ssl --parallel --stream",
"build": "lerna run build",
"lint": "lerna run lint",
"test": "lerna run test",
"clean": "rimraf --glob 'packages/*/dist/*' 'sandbox/*'",
"preversion": "yarn lint",
"version": "yarn clean && yarn build",
"postversion": "git push && git push --tags"
},
"devDependencies": {
"@types/meow": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.1",
"lerna": "^8.1.8",
"meow": "^13.2.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"typescript": "5.5.4",
"vite": "^5.4.6"
},
"resolutions": {
"eslint": "^8.57.0",
"typescript": "^5.2.2",
"vite": "^5.3.4"
}
}
16 changes: 16 additions & 0 deletions packages/create-angular/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

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

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Loading

0 comments on commit d77361e

Please sign in to comment.