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 Angular template #167

Merged
merged 6 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .scripts/generate-templates-matrix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const changedFiles = process.argv.slice(2);

const nodeJsTemplates = [
"angular",
"svelte",
"svelte-ts",
"vue",
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/fragments/fragment-angular/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer", "angular.ng-template"]
}
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tauri + Angular

This template should help get you started developing with Tauri and Angular.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) + [Angular Language Service](https://marketplace.visualstudio.com/items?itemName=Angular.ng-template)
11 changes: 11 additions & 0 deletions packages/cli/fragments/fragment-angular/_cta_manifest_
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

beforeDevCommand = {{pkg_manager_run_command}} dev
beforeBuildCommand = {{pkg_manager_run_command}} build
devPath = http://localhost:4200
eneajaho marked this conversation as resolved.
Show resolved Hide resolved
distDir = ../dist

[files]
tauri.svg = src/assets/tauri.svg
25 changes: 25 additions & 0 deletions packages/cli/fragments/fragment-angular/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
.angular

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
84 changes: 84 additions & 0 deletions packages/cli/fragments/fragment-angular/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
eneajaho marked this conversation as resolved.
Show resolved Hide resolved
"projects": {
"{{package_name}}": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/style.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "{{package_name}}:build:production"
},
"development": {
"browserTarget": "{{package_name}}:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "{{package_name}}:build"
}
}
}
}
}
}
35 changes: 35 additions & 0 deletions packages/cli/fragments/fragment-angular/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "{{package_name}}",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"tauri": "tauri",
"ng": "ng",
"dev": "ng serve",
eneajaho marked this conversation as resolved.
Show resolved Hide resolved
"build": "ng build",
"watch": "ng build --watch --configuration development"
},
"dependencies": {
"@tauri-apps/api": "^1.0.2",
"@angular/animations": "^14.2.0",
"@angular/common": "^14.2.0",
"@angular/compiler": "^14.2.0",
"@angular/core": "^14.2.0",
"@angular/forms": "^14.2.0",
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@tauri-apps/cli": "^1.0.5",
"@angular-devkit/build-angular": "^14.2.2",
"@angular/cli": "~14.2.2",
"@angular/compiler-cli": "^14.2.0",
"typescript": "~4.7.2"
}
}

46 changes: 46 additions & 0 deletions packages/cli/fragments/fragment-angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component } from '@angular/core';
import { invoke } from '@tauri-apps/api/tauri';

@Component({
selector: 'app-root',
template: `
<div class="container">
<h1>Welcome to Tauri + Angular!</h1>

<div class="row">
<a href="https://tauri.app" target="_blank">
<img src="/assets/tauri.svg" class="logo tauri" alt="Tauri logo" />
</a>
<a href="https://angular.io" target="_blank">
<img src="/assets/angular.svg" class="logo angular" alt="Angular logo" />
</a>
</div>

<p>Click on the logos to learn more about the frameworks</p>

<div class="row">
<div>
<input #nameInput placeholder="Enter a name..." />
eneajaho marked this conversation as resolved.
Show resolved Hide resolved
<button type="button" (click)="greet(nameInput.value)">Greet</button>
</div>
</div>

<p>{{ greetingMessage }}</p>
</div>
`,
styles: [`
.logo.angular:hover {
filter: drop-shadow(0 0 2em #e32727);
}
`],
standalone: true,
})
export class AppComponent {
greetingMessage = '';

greet(name: string): void {
invoke<string>('greet', { name }).then((text) => {
this.greetingMessage = text;
});
}
}
16 changes: 16 additions & 0 deletions packages/cli/fragments/fragment-angular/src/assets/angular.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
};

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
15 changes: 15 additions & 0 deletions packages/cli/fragments/fragment-angular/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Tauri + Angular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>

<body>
<app-root></app-root>
</body>
</html>
11 changes: 11 additions & 0 deletions packages/cli/fragments/fragment-angular/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { enableProdMode } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

import { environment } from './environments/environment';

if (environment.production) {
enableProdMode();
}

bootstrapApplication(AppComponent).catch(err => console.error(err));
53 changes: 53 additions & 0 deletions packages/cli/fragments/fragment-angular/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes recent versions of Safari, Chrome (including
* Opera), Edge on the desktop, and iOS and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/

/***************************************************************************************************
* BROWSER POLYFILLS
*/

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/

/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.


/***************************************************************************************************
* APPLICATION IMPORTS
*/
15 changes: 15 additions & 0 deletions packages/cli/fragments/fragment-angular/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}