Skip to content

Commit d65d086

Browse files
[debugger] Bare minimum of tfjs debugger angular app
1 parent ad22722 commit d65d086

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+10298
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy TFJS Debugger Site to Live
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'toolings/tfjs-debugger/**'
9+
10+
jobs:
11+
deploy_live_website:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
shell: bash
16+
working-directory: toolings/tfjs-debugger
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-node@v2
20+
with:
21+
node-version: 12
22+
- run: |
23+
yarn
24+
yarn build
25+
- uses: FirebaseExtended/action-hosting-deploy@v0
26+
with:
27+
repoToken: '${{ secrets.GITHUB_TOKEN }}'
28+
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_JSTENSORFLOW }}'
29+
projectId: jstensorflow
30+
target: tfjs-debugger
31+
channelId: live
32+
entryPoint: toolings/tfjs-debugger/

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

.tslint/noImportsFromDistRule.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use strict";
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = function (d, b) {
4+
extendStatics = Object.setPrototypeOf ||
5+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7+
return extendStatics(d, b);
8+
};
9+
return function (d, b) {
10+
extendStatics(d, b);
11+
function __() { this.constructor = d; }
12+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13+
};
14+
})();
15+
exports.__esModule = true;
16+
var Lint = require("tslint");
17+
var Rule = /** @class */ (function (_super) {
18+
__extends(Rule, _super);
19+
function Rule() {
20+
return _super !== null && _super.apply(this, arguments) || this;
21+
}
22+
Rule.prototype.apply = function (sourceFile) {
23+
return this.applyWithWalker(new NoImportsFromDistWalker(sourceFile, this.getOptions()));
24+
};
25+
Rule.FAILURE_STRING = "importing from dist/ is prohibited. Please use public API";
26+
return Rule;
27+
}(Lint.Rules.AbstractRule));
28+
exports.Rule = Rule;
29+
var NoImportsFromDistWalker = /** @class */ (function (_super) {
30+
__extends(NoImportsFromDistWalker, _super);
31+
function NoImportsFromDistWalker() {
32+
return _super !== null && _super.apply(this, arguments) || this;
33+
}
34+
NoImportsFromDistWalker.prototype.visitImportDeclaration = function (node) {
35+
var importFrom = node.moduleSpecifier.getText();
36+
var reg = /@tensorflow\/tfjs[-a-z]*\/dist/;
37+
if (importFrom.match(reg)) {
38+
var fix = new Lint.Replacement(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), importFrom.replace(/\/dist[\/]*/, ''));
39+
this.addFailure(this.createFailure(node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(), Rule.FAILURE_STRING, fix));
40+
}
41+
_super.prototype.visitImportDeclaration.call(this, node);
42+
};
43+
return NoImportsFromDistWalker;
44+
}(Lint.RuleWalker));

.tslint/noImportsFromDistRule.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as Lint from 'tslint';
2+
import * as ts from 'typescript';
3+
4+
export class Rule extends Lint.Rules.AbstractRule {
5+
public static FAILURE_STRING =
6+
'importing from dist/ is prohibited. Please use public API';
7+
8+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
9+
return this.applyWithWalker(
10+
new NoImportsFromDistWalker(sourceFile, this.getOptions()));
11+
}
12+
}
13+
14+
class NoImportsFromDistWalker extends Lint.RuleWalker {
15+
public visitImportDeclaration(node: ts.ImportDeclaration) {
16+
const importFrom = node.moduleSpecifier.getText();
17+
const reg = /@tensorflow\/tfjs[-a-z]*\/dist/;
18+
if (importFrom.match(reg)) {
19+
const fix = new Lint.Replacement(
20+
node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(),
21+
importFrom.replace(/\/dist[\/]*/, ''));
22+
23+
this.addFailure(this.createFailure(
24+
node.moduleSpecifier.getStart(), node.moduleSpecifier.getWidth(),
25+
Rule.FAILURE_STRING, fix));
26+
}
27+
28+
super.visitImportDeclaration(node);
29+
}
30+
}

package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "sig-tfjs",
3+
"version": "0.0.1",
4+
"license": "Apache-2.0",
5+
"scripts": {
6+
"presubmit": "ts-node presubmit.ts"
7+
},
8+
"devDependencies": {
9+
"@types/node": "~16.10.9",
10+
"@types/shelljs": "~0.8.9",
11+
"fs": "~0.0.1-security",
12+
"jasmine": "~3.10.0",
13+
"shelljs": "0.8.4",
14+
"ts-node": "~10.3.0",
15+
"tslint": "~6.1.3",
16+
"tslint-no-circular-imports": "~0.7.0",
17+
"typescript": "4.4.4",
18+
"yalc": "~1.0.0-pre.53"
19+
},
20+
"resolutions": {
21+
"path-parse": "1.0.7"
22+
}
23+
}

presubmit.ts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
18+
import * as fs from 'fs';
19+
import {join} from 'path';
20+
import * as shell from 'shelljs';
21+
22+
// Exit if any commands error.
23+
shell.set('-e');
24+
process.on('unhandledRejection', e => {
25+
throw e;
26+
});
27+
28+
// Read sub dirs that are under the parent dirs below.
29+
const parentDirs = ['.', 'toolings'];
30+
const dirs: string[] = [];
31+
parentDirs.forEach(curParentDir => {
32+
const curDirs =
33+
fs.readdirSync(curParentDir)
34+
.filter(f => fs.statSync(join(curParentDir, f)).isDirectory())
35+
.filter(f => !f.startsWith('.') && f !== 'node_modules');
36+
dirs.push(...curDirs.map(curDir => join(curParentDir, curDir)));
37+
})
38+
39+
dirs.forEach(dir => {
40+
shell.cd(dir);
41+
42+
if (!fs.existsSync('./package.json')) {
43+
shell.cd('../');
44+
return;
45+
}
46+
47+
const packageJSON: {'scripts': {[key: string]: string}} =
48+
JSON.parse(fs.readFileSync('./package.json', {encoding: 'utf-8'}));
49+
if (packageJSON['scripts']['test-ci'] != null) {
50+
console.log(`~~~~~~~~~~~~ Testing ${dir} ~~~~~~~~~~~~`);
51+
shell.exec('yarn');
52+
shell.exec('yarn test-ci');
53+
console.log('\n');
54+
} else if (packageJSON['scripts']['test'] != null) {
55+
console.log(`~~~~~~~~~~~~ Testing ${dir} ~~~~~~~~~~~~`);
56+
shell.exec('yarn');
57+
shell.exec('yarn test');
58+
console.log('\n');
59+
}
60+
61+
if (packageJSON['scripts']['lint'] != null) {
62+
console.log(`~~~~~~~~~~~~ Linting ${dir} ~~~~~~~~~~~~`);
63+
shell.exec('yarn');
64+
shell.exec('yarn lint');
65+
console.log('\n');
66+
}
67+
shell.cd('../');
68+
});
+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.

toolings/tfjs-debugger/.editorconfig

+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

toolings/tfjs-debugger/.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
/.firebase
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db

toolings/tfjs-debugger/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TFJS Debugger
2+
3+
*Work in progress*

0 commit comments

Comments
 (0)