diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 000000000..c0bfb3028 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "angularfire2-test" + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..772bfbbb9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +src/**/firebase.ts linguist-generated=true +src/**/rxfire.ts linguist-generated=true +src/compat/**/base.ts linguist-generated=true +samples/**/* linguist-generated=true +yarn.lock linguist-generated=true \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..a1fbcb71c --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '20 23 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # âšī¸ Command-line programs to run using the OS shell. + # đ https://git.io/JvXDl + + # âī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..ebb9d9b3e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,220 @@ +name: Test and publish + +on: + push: + branches: + - main + paths-ignore: + - "**/*.md" + pull_request: + branches: + - "**" + release: + types: + - published + schedule: + - cron: 0 0 * * 1-5 + +jobs: + build: + runs-on: ubuntu-latest + name: Build + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: '20' + check-latest: false + - name: angular build cache + uses: actions/cache@v3 + with: + path: ./.angular + key: angular-cache + - name: node_modules cache + uses: actions/cache@v3 + id: node_modules_cache + with: + path: ./node_modules + key: ${{ runner.os }}-20-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-20- + - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' + run: | + npm ci + - name: Build + run: ./tools/build.sh + - name: 'Upload Artifact' + uses: actions/upload-artifact@v4 + with: + name: angularfire-${{ github.run_id }} + path: dist + retention-days: 1 + + test: + runs-on: ${{ matrix.os }} + needs: build + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + node: ["18", "20", "22"] + fail-fast: false + name: Test Node ${{ matrix.node }} (${{ matrix.os }}) + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + check-latest: true + - name: node_modules cache + id: node_modules_cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.node }}- + - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' + run: npm ci + - name: Download Artifacts + uses: actions/download-artifact@v4 + - name: Relocate Artifacts + run: mv angularfire-${{ github.run_id }} dist + - name: Test Node + run: | + npm run build:jasmine + npm run test:node + + browser: + runs-on: ${{ matrix.os }} + needs: build + name: Test ${{ matrix.browser }} + strategy: + matrix: + os: [ ubuntu-latest ] + browser: [ chrome-headless, firefox-headless ] + # TODO(davideast): Figure out why Safari tests timeout only on CI + # include: + # - os: macos-latest + # browser: safari + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 20 + check-latest: false + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + - name: node_modules cache + id: node_modules_cache + uses: actions/cache@v3 + with: + path: ./node_modules + key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.node }}- + - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' + run: npm ci + - name: Firebase emulator cache + uses: actions/cache@v3 + with: + path: ~/.cache/firebase/emulators + key: firebase_emulators + - name: Download Artifacts + uses: actions/download-artifact@v4 + - name: Relocate Artifacts + run: mv angularfire-${{ github.run_id }} dist + - name: Test browser + run: npm run test:${{ matrix.browser }} + + contribute: + runs-on: ${{ matrix.os }} + name: Contribute Node ${{ matrix.node }} (${{ matrix.os }}) + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + node: ["20"] + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + check-latest: true + - name: node_modules cache + uses: actions/cache@v3 + id: node_modules_cache + with: + path: ./node_modules + key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.node }}- + - name: Install deps + if: steps.node_modules_cache.outputs.cache-hit != 'true' + run: npm ci + #- name: Lint + # run: npm run lint + - name: Build + run: npm run build + - name: Test Node + run: | + npm run build:jasmine + npm run test:node + - name: Firebase emulator cache + uses: actions/cache@v3 + with: + path: ~/.cache/firebase/emulators + key: firebase_emulators + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + - name: Test headless + run: npm run test:chrome-headless + # Tests are flaky on Windows + continue-on-error: ${{ matrix.os == 'windows-latest' }} + + # Break the branch protection test into a seperate step, so we can manage the matrix more easily + test_and_contribute: + runs-on: ubuntu-latest + name: Branch protection + needs: ['test', 'contribute', 'browser'] + steps: + - run: true + + publish: + runs-on: ubuntu-latest + name: Publish (NPM) + needs: ['build', 'test', 'browser'] + if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} + steps: + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org/' + check-latest: false + - name: 'Download Artifacts' + uses: actions/download-artifact@v4 + - name: Publish + run: | + cd ./angularfire-${{ github.run_id }}/packages-dist + chmod +x publish.sh + ./publish.sh + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 9298d341a..beb5d455e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,22 @@ typings/ npm-debug.log .idea/ .vscode/settings.json -angularfire2-*.tgz \ No newline at end of file +angular-fire-*.tgz +angularfire2-*.tgz +*.ngfactory.ts +*.ngsummary.json +.DS_Store +yarn-error.log +*.bak +yarn.lock +test/ng-build/**/yarn.lock +tools/build.js +coverage +*.log +api-*.json +angularfire.tgz +unpack.sh +publish.sh +.firebase +.angular +.vscode \ No newline at end of file diff --git a/.npmignore b/.npmignore index 77923cf1e..02a57a315 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,7 @@ *.spec.* - +test-config.* +publish.sh +__ivy_ngcc__/ +*.min.js +*.min.js.map +*.__ivy_ngcc_bak \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..1a2f5bd20 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9f03314c1..000000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: node_js -sudo: false -node_js: -- '6' - -addons: - firefox: latest - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - -cache: - directories: - - node_modules - -env: - - CXX=g++-4.8 - -install: - - npm install -g yarn - - yarn install - -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - -script: - - npm run build - - ./node_modules/.bin/karma start --single-run --browsers Firefox --reporters mocha - # Make sure the build that ships to npm builds without errors - - npm run build_npm - # Run integration test to make sure our typings are correct for user-land. - - node tools/run-typings-test.js - # Can't run until https://github.com/angular/protractor/issues/2784 is resolved - #- ./node_modules/.bin/protractor protractor.conf.js --browser firefox - -notifications: - webhooks: - on_success: always # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: false # default: false diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 5966e725d..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,207 +0,0 @@ - -# [4.0.0-rc0](https://github.com/angular/angularfire2/compare/2.0.0-beta.8...v4.0.0-rc0) (2017-05-02) - - -### Bug Fixes - -* **auth:** Use the injected app ([980c447](https://github.com/angular/angularfire2/commit/980c447)) -* **build:** Add package.json files for deep paths ([cd5f2d1](https://github.com/angular/angularfire2/commit/cd5f2d1)), closes [#880](https://github.com/angular/angularfire2/issues/880) -* **database:** Fix test TypeScript errors ([750737c](https://github.com/angular/angularfire2/commit/750737c)), closes [#875](https://github.com/angular/angularfire2/issues/875) -* **database:** use switchMap when a list's query changes ([#831](https://github.com/angular/angularfire2/issues/831)) ([b85147d](https://github.com/angular/angularfire2/commit/b85147d)), closes [#830](https://github.com/angular/angularfire2/issues/830) - - -### Features - -* **auth:** New Auth API ([12aa422](https://github.com/angular/angularfire2/commit/12aa422)) -* **database:** Add AngularFireDatabaseModule ([b388627](https://github.com/angular/angularfire2/commit/b388627)) -* **database:** support optional endAt/equalTo key ([#838](https://github.com/angular/angularfire2/issues/838)) ([e146492](https://github.com/angular/angularfire2/commit/e146492)), closes [#837](https://github.com/angular/angularfire2/issues/837) -* **rc:** Implement rc0 API ([398e4e2](https://github.com/angular/angularfire2/commit/398e4e2)) - - - -# [2.0.0-beta.8](https://github.com/angular/angularfire2/compare/2.0.0-beta7...v2.0.0-beta.8) (2017-02-16) - - -### Bug Fixes - -* **database:** allow null values for equalTo, etc. ([#809](https://github.com/angular/angularfire2/issues/809)) ([561e7b7](https://github.com/angular/angularfire2/commit/561e7b7)) -* **database:** call apply instead of call ([7a85bd2](https://github.com/angular/angularfire2/commit/7a85bd2)) -* **database:** retrieve initial list content once ([#820](https://github.com/angular/angularfire2/issues/820)) ([5c5ff7b](https://github.com/angular/angularfire2/commit/5c5ff7b)), closes [#819](https://github.com/angular/angularfire2/issues/819) -* **database:** store unwrapped snapshots ([9f3c47b](https://github.com/angular/angularfire2/commit/9f3c47b)), closes [#791](https://github.com/angular/angularfire2/issues/791) -* **utils:** Make object $key and $exists properties non-enumerable ([253401f](https://github.com/angular/angularfire2/commit/253401f)) -* **utils:** Minor formatting improvement ([fc3774a](https://github.com/angular/angularfire2/commit/fc3774a)) - - -### Features - -* **database:** adds auditTime for queries ([f9cb5c3](https://github.com/angular/angularfire2/commit/f9cb5c3)), closes [#389](https://github.com/angular/angularfire2/issues/389) [#770](https://github.com/angular/angularfire2/issues/770) -* **database:** support the optional startAt key ([#821](https://github.com/angular/angularfire2/issues/821)) ([c469b11](https://github.com/angular/angularfire2/commit/c469b11)) - - - - -# [2.0.0-beta.7](https://github.com/angular/angularfire2/compare/2.0.0-beta.6...v2.0.0-beta.7) (2017-01-13) - - -### Breaking changes - -* **auth:** Remove `FirebaseAuth` in favor of `AngularFireAuth`. ([d422e6])(https://github.com/angular/angularfire2/commit/d422e62b46a80d9fb12c9a9e2cf1cf2f7db04dd3) - -### Bug Fixes - -* **aot:** Remove AuthBackend param for AOT support ([f875360](https://github.com/angular/angularfire2/commit/f875360)) -* **auth_backend:** Update logout method to return a promise ([169ce64](https://github.com/angular/angularfire2/commit/169ce64)), closes [#583](https://github.com/angular/angularfire2/issues/583) -* **config:** Add messagingSenderId to FirebaseAppConfig ([9c84869](https://github.com/angular/angularfire2/commit/9c84869)) -* **database:** Allow null values for equalTo, etc. ([70a3e94](https://github.com/angular/angularfire2/commit/70a3e94)), closes [#704](https://github.com/angular/angularfire2/issues/704) -* **database:** Removed unused query option ([9cbc59b](https://github.com/angular/angularfire2/commit/9cbc59b)), closes [#706](https://github.com/angular/angularfire2/issues/706) -* **list:** Fix FirebaseListObservable emit as array bug [#574](https://github.com/angular/angularfire2/issues/574) ([ce3de04](https://github.com/angular/angularfire2/commit/ce3de04)) -* **module:** Conditionally pass app name ([8427009](https://github.com/angular/angularfire2/commit/8427009)) - -### Features - -* **module:** Add a custom FirebaseApp name ([73a3e26](https://github.com/angular/angularfire2/commit/73a3e26)) - - - - -# [2.0.0-beta.6-preview](https://github.com/angular/angularfire2/compare/2.0.0-beta.5...v2.0.0-beta.6-preview) (2016-11-02) - - -### Bug Fixes - -* **Database:** use Zone scheduler for object and list factories ([e18da0e](https://github.com/angular/angularfire2/commit/e18da0e)), closes [#637](https://github.com/angular/angularfire2/issues/637) -* **AoT:** change constructor param interface type annotation to any ([2c0a57f](https://github.com/angular/angularfire2/commit/2c0a57f)) -* **build:** Fix npm test and test:watch commands for windows ([86b4b24](https://github.com/angular/angularfire2/commit/86b4b24)), closes [#217](https://github.com/angular/angularfire2/issues/217) -* **database:** Add $ref to observables ([#447](https://github.com/angular/angularfire2/issues/447)) ([a53fac0](https://github.com/angular/angularfire2/commit/a53fac0)), closes [#294](https://github.com/angular/angularfire2/issues/294) -* **imports:** add firebase imports to all places that reference firebase namespace ([c3a954c](https://github.com/angular/angularfire2/commit/c3a954c)), closes [#525](https://github.com/angular/angularfire2/issues/525) - - -### Features - -* **docs:** Add AoT installation and setup ([#546](https://github.com/angular/angularfire2/issues/546)) ([7c20d13](https://github.com/angular/angularfire2/commit/7c20d13)) -* **docs:** update installation guide to latest cli version ([#519](https://github.com/angular/angularfire2/issues/519)) ([648666f](https://github.com/angular/angularfire2/commit/648666f)) -* **hmr:** Add Hot module reloading ([c32a008](https://github.com/angular/angularfire2/commit/c32a008)) - -### Notes - -A TypeScript issue with the previous release has been fixed, where errors about a missing `firebase` namespace were reported. For -applications that worked around this issue by manually adding the `firebase.d.ts` typings to `tsconfig.json`, those typings -should now be removed since the firebase namespace should automatically be resolved within AngularFire. -See [this issue](https://github.com/angular/angularfire2/issues/525) for more context. - - -# [2.0.0-beta.5](https://github.com/angular/angularfire2/compare/2.0.0-beta.4...v2.0.0-beta.5) (2016-09-15) - - -### Bug Fixes - -* **docs:** Remove [@next](https://github.com/next) install ([5984a99](https://github.com/angular/angularfire2/commit/5984a99)) -* **docs:** typos ([197026a](https://github.com/angular/angularfire2/commit/197026a)) -* **docs:** Update for beta.4 ([f2d5ba5](https://github.com/angular/angularfire2/commit/f2d5ba5)) -* **docs:** Update for beta.4 ([b347e16](https://github.com/angular/angularfire2/commit/b347e16)) -* **firebase_*_factory.js:** Fix calls to off() which inadvertently cancel all listeners on the path ([#469](https://github.com/angular/angularfire2/issues/469)) ([b4fb281](https://github.com/angular/angularfire2/commit/b4fb281)), closes [#443](https://github.com/angular/angularfire2/issues/443) -* **package:** Version number ([986685a](https://github.com/angular/angularfire2/commit/986685a)) - - -### Features - -* **utils:** Add $exists method to AFUnwrappedSnapshot ([#471](https://github.com/angular/angularfire2/issues/471)) ([f67aab1](https://github.com/angular/angularfire2/commit/f67aab1)) -* upgrade to RC7 ([#505](https://github.com/angular/angularfire2/issues/505)) ([2410b2d](https://github.com/angular/angularfire2/commit/2410b2d)) - -### BREAKING CHANGES - -The way this project is packaged has changed to be consistent with other Angular packages. -Previously: - - * The project just consisted of CommonJS modules, with `angularfire2.js` as the main entry point. - * The project provided an `es6` directory which contained es2015 modules and es2015 JS - * Package.json included `main` and `jsnext:main` fields, pointing to `angularfire2.js` and `es6/angularfire2.js`, respectively. - -Now: - - * The project ships ES2015 modules with ES5 JS at the root, as well as an ES5 UMD bundle at `bundles/angulafire2.umd.js` - * The `main` field of `package.json` points to `bundles/angularfire2.umd.js`. - * Instead of `jsnext:main`, we're using the `module` field of package.json to point to `index.js`. - * Instead of `angularfire2.js` being the main entry point, an `index.js` has been added (though angulafire2.js hasn't changed significantly). - -If you're using Rollup or Webpack, they should _just work_ with this new setup (please open issues if not). If using SystemJS, you should be able to -add `format: 'esm'` inside of the packages configuration, and it should load and parse the es2015 modules correctly. - -The addition of the umd bundle will also make it possible to use AngularFire2 in a ` + + +
+ +