Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 80a3e0c

Browse files
feat: add example with angular 12 (#4)
1 parent 1e9f277 commit 80a3e0c

29 files changed

+2051
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
17+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

examples/browser-angular/.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.sass-cache
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
npm-debug.log
39+
yarn-error.log
40+
testem.log
41+
/typings
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db

examples/browser-angular/README.md

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# BrowserAngular
2+
3+
<p align="center">
4+
<a href="https://js.ipfs.io" title="JS IPFS">
5+
<img src="https://ipfs.io/ipfs/Qme6KJdKcp85TYbLxuLV7oQzMiLremD7HMoXLZEmgo6Rnh/js-ipfs-sticker.png" alt="IPFS in JavaScript logo" width="244" />
6+
</a>
7+
</p>
8+
9+
<h3 align="center"><b>IPFS React App</b></h3>
10+
11+
<p align="center">
12+
<b><i>Using js-ipfs in a `create-react-app`</i></b>
13+
<br />
14+
<br />
15+
<img src="https://raw.githubusercontent.com/jlord/forkngo/gh-pages/badges/cobalt.png" width="200">
16+
<br>
17+
<a href="https://github.com/ipfs/js-ipfs/tree/master/docs">Explore the docs</a>
18+
·
19+
<a href="https://codesandbox.io/">View Demo</a>
20+
·
21+
<a href="https://github.com/ipfs/js-ipfs/issues">Report Bug</a>
22+
·
23+
<a href="https://github.com/ipfs/js-ipfs/issues">Request Feature</a>
24+
</p>
25+
26+
## Table of Contents
27+
28+
- [BrowserAngular](#browserangular)
29+
- [Table of Contents](#table-of-contents)
30+
- [About The Project](#about-the-project)
31+
- [Getting Started](#getting-started)
32+
- [Pre requisites](#pre-requisites)
33+
- [Installation and Running example](#installation-and-running-example)
34+
- [Available Scripts from create-react-app](#available-scripts-from-create-react-app)
35+
- [Development server](#development-server)
36+
- [Code scaffolding](#code-scaffolding)
37+
- [Build](#build)
38+
- [Running unit tests](#running-unit-tests)
39+
- [Running end-to-end tests](#running-end-to-end-tests)
40+
- [Further help](#further-help)
41+
- [Usage](#usage)
42+
- [Documentation](#documentation)
43+
- [Contributing](#contributing)
44+
- [Want to hack on IPFS?](#want-to-hack-on-ipfs)
45+
46+
## About The Project
47+
48+
- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs)
49+
- Look into other [examples](https://github.com/ipfs/js-ipfs/tree/master/examples) to learn how to spawn an IPFS node in Node.js and in the Browser
50+
- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node
51+
- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it
52+
- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs
53+
- Check out https://docs.ipfs.io for tips, how-tos and more
54+
- See https://blog.ipfs.io for news and more
55+
- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
56+
57+
## Getting Started
58+
59+
### Pre requisites
60+
61+
Make sure you have installed all of the following prerequisites on your development machine:
62+
63+
- Git - [Download & Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.
64+
- Node.js - [Download & Install Node.js](https://nodejs.org/en/download/) and the npm package manager.
65+
66+
### Installation and Running example
67+
68+
```console
69+
> npm install
70+
> npm start
71+
```
72+
73+
Now open your browser at `http://localhost:3000`
74+
75+
### Available Scripts from create-react-app
76+
77+
In the project directory, you can run:
78+
79+
#### Development server
80+
81+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
82+
83+
#### Code scaffolding
84+
85+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
86+
87+
#### Build
88+
89+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
90+
91+
#### Running unit tests
92+
93+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
94+
95+
#### Running end-to-end tests
96+
97+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
98+
99+
#### Further help
100+
101+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
102+
103+
## Usage
104+
105+
A minimal demonstration of how to use js-ipfs in a `angular` generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.1.2.
106+
107+
Check the `ipfs.service.ts` file to how to use the basic of ipfs.
108+
109+
_For more examples, please refer to the [Documentation](#documentation)_
110+
111+
## Documentation
112+
113+
- [Config](https://docs.ipfs.io/)
114+
- [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api)
115+
- [Examples](https://github.com/ipfs/js-ipfs/tree/master/examples)
116+
- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)
117+
118+
## Contributing
119+
120+
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
121+
122+
1. Fork the IPFS Project
123+
2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
124+
3. Commit your Changes (`git commit -a -m 'feat: add some amazing feature'`)
125+
4. Push to the Branch (`git push origin feature/amazing-feature`)
126+
5. Open a Pull Request
127+
128+
## Want to hack on IPFS?
129+
130+
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
131+
132+
The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:
133+
134+
Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md).
135+
136+
- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
137+
- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now
138+
- **Perform code reviews** More eyes will help
139+
a. speed the project along
140+
b. ensure quality, and
141+
c. reduce possible future bugs.
142+
- **Add tests**. There can never be enough tests.
143+
- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next

examples/browser-angular/angular.json

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"browser-angular": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:application": {
10+
"strict": true
11+
}
12+
},
13+
"root": "",
14+
"sourceRoot": "src",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-builders/custom-webpack:browser",
19+
"options": {
20+
"customWebpackConfig": {
21+
"path": "./extra-webpack.config.ts"
22+
},
23+
"outputPath": "dist/",
24+
"index": "src/index.html",
25+
"main": "src/main.ts",
26+
"polyfills": "src/polyfills.ts",
27+
"tsConfig": "tsconfig.app.json",
28+
"assets": ["src/favicon.ico", "src/assets"],
29+
"styles": ["src/styles.css"],
30+
"scripts": []
31+
},
32+
"configurations": {
33+
"production": {
34+
"budgets": [
35+
{
36+
"type": "initial",
37+
"maximumWarning": "1mb",
38+
"maximumError": "4mb"
39+
},
40+
{
41+
"type": "anyComponentStyle",
42+
"maximumWarning": "2kb",
43+
"maximumError": "4kb"
44+
}
45+
],
46+
"fileReplacements": [
47+
{
48+
"replace": "src/environments/environment.ts",
49+
"with": "src/environments/environment.prod.ts"
50+
}
51+
],
52+
"outputHashing": "all"
53+
},
54+
"development": {
55+
"buildOptimizer": false,
56+
"optimization": false,
57+
"vendorChunk": true,
58+
"extractLicenses": false,
59+
"sourceMap": true,
60+
"namedChunks": true
61+
}
62+
},
63+
"defaultConfiguration": "production"
64+
},
65+
"serve": {
66+
"builder": "@angular-builders/custom-webpack:dev-server",
67+
"options": {
68+
"browserTarget": "browser-angular:build"
69+
},
70+
"configurations": {
71+
"production": {
72+
"browserTarget": "browser-angular:build:production"
73+
},
74+
"development": {
75+
"browserTarget": "browser-angular:build:development"
76+
}
77+
},
78+
"defaultConfiguration": "development"
79+
},
80+
"extract-i18n": {
81+
"builder": "@angular-devkit/build-angular:extract-i18n",
82+
"options": {
83+
"browserTarget": "browser-angular:build"
84+
}
85+
},
86+
"test": {
87+
"builder": "@angular-devkit/build-angular:karma",
88+
"options": {
89+
"main": "src/test.ts",
90+
"polyfills": "src/polyfills.ts",
91+
"tsConfig": "tsconfig.spec.json",
92+
"karmaConfig": "karma.conf.js",
93+
"assets": ["src/favicon.ico", "src/assets"],
94+
"styles": ["src/styles.css"],
95+
"scripts": []
96+
}
97+
}
98+
}
99+
}
100+
},
101+
"defaultProject": "browser-angular"
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Configuration, ProvidePlugin } from 'webpack';
2+
import * as NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
3+
4+
export default {
5+
plugins: [
6+
// fixes Module not found: Error: Can't resolve 'stream' in '.../node_modules/nofilter/lib'
7+
new NodePolyfillPlugin({}),
8+
// Note: stream-browserify has assumption about `Buffer` global in its
9+
// dependencies causing runtime errors. This is a workaround to provide
10+
// global `Buffer` until https://github.com/isaacs/core-util-is/issues/29
11+
// is fixed.
12+
new ProvidePlugin({
13+
global: ['global'],
14+
Buffer: ['buffer', 'Buffer'],
15+
process: 'process/browser',
16+
})
17+
],
18+
} as Configuration;
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
clearContext: false // leave Jasmine Spec Runner output visible in browser
23+
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true // removes the duplicated traces
26+
},
27+
coverageReporter: {
28+
dir: require('path').join(__dirname, './coverage/browser-angular'),
29+
subdir: '.',
30+
reporters: [
31+
{ type: 'html' },
32+
{ type: 'text-summary' }
33+
]
34+
},
35+
reporters: ['progress', 'kjhtml'],
36+
port: 9876,
37+
colors: true,
38+
logLevel: config.LOG_INFO,
39+
autoWatch: true,
40+
browsers: ['Chrome'],
41+
singleRun: false,
42+
restartOnFileChange: true
43+
});
44+
};

0 commit comments

Comments
 (0)