mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
added correct packaging for browser tasks
This commit is contained in:
parent
aa578e8447
commit
6876ebcf2a
@ -10,8 +10,8 @@ If you notice bug or have something not working please report an issue, we'll tr
|
||||
More documentation and features expected to be soon. Feel free to contribute.
|
||||
|
||||
TypeORM is an [Object Relational Mapper](1) (ORM) for node.js written in
|
||||
Typescript that can be used with Typescript or Javascript (ES5, ES6, ES7).
|
||||
Its goal to always support latest Javascript features and provide features
|
||||
TypeScript that can be used with TypeScript or JavaScript (ES5, ES6, ES7).
|
||||
Its goal to always support latest JavaScript features and provide features
|
||||
that help you to develop any kind of applications that use database - from
|
||||
small applications with a few tables to large scale enterprise applications.
|
||||
TypeORM helps you to:
|
||||
|
||||
1011
README_BROWSER.md
Normal file
1011
README_BROWSER.md
Normal file
File diff suppressed because it is too large
Load Diff
91
gulpfile.ts
91
gulpfile.ts
@ -40,7 +40,12 @@ export class Gulpfile {
|
||||
.pipe(shell(["tsc"]));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Build and packaging for browser
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Copies all source files into destination folder in a correct structure.
|
||||
*/
|
||||
@Task()
|
||||
browserCopySources() {
|
||||
@ -56,6 +61,9 @@ export class Gulpfile {
|
||||
.pipe(gulp.dest("./build/browser/typeorm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates special main file for browser build.
|
||||
*/
|
||||
@Task()
|
||||
browserCopyMainBrowserFile() {
|
||||
return gulp.src("./package.json", { read: false })
|
||||
@ -63,6 +71,9 @@ export class Gulpfile {
|
||||
.pipe(gulp.dest("./build/browser"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces PlatformTools with browser-specific implementation called BrowserPlatformTools.
|
||||
*/
|
||||
@Task()
|
||||
browserCopyPlatformTools() {
|
||||
return gulp.src("./src/platform/BrowserPlatformTools.ts")
|
||||
@ -71,14 +82,13 @@ export class Gulpfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs typescript files compilation.
|
||||
* Runs files compilation of browser-specific source code.
|
||||
*/
|
||||
@MergedTask()
|
||||
browserCompile() {
|
||||
const tsProject = ts.createProject("tsconfig.json", {
|
||||
outFile: "typeorm-browser.js",
|
||||
module: "system",
|
||||
target: "es6",
|
||||
typescript: require("typescript")
|
||||
});
|
||||
const tsResult = gulp.src(["./build/browser/**/*.ts", "./node_modules/@types/**/*.ts"])
|
||||
@ -86,7 +96,7 @@ export class Gulpfile {
|
||||
.pipe(tsProject());
|
||||
|
||||
return [
|
||||
tsResult.dts.pipe(gulp.dest("./build/package")),
|
||||
tsResult.dts.pipe(gulp.dest("./build/browser-package")),
|
||||
tsResult.js
|
||||
.pipe(sourcemaps.write(".", { sourceRoot: "", includeContent: true }))
|
||||
.pipe(gulp.dest("./build/browser-package"))
|
||||
@ -94,30 +104,69 @@ export class Gulpfile {
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@SequenceTask()
|
||||
browser() {
|
||||
return [["browserCopySources", "browserCopyMainBrowserFile", "browserCopyPlatformTools"], "browserCompile", "uglify"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Uglifys all code.
|
||||
*/
|
||||
@Task()
|
||||
uglify() {
|
||||
browserUglify() {
|
||||
return gulp.src("./build/browser-package/*.js")
|
||||
.pipe(uglify())
|
||||
.pipe(rename("typeorm-browser.min.js"))
|
||||
.pipe(gulp.dest("./build/browser-package"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies README_BROWSER.md into README.md for the typeorm-browser package.
|
||||
*/
|
||||
@Task()
|
||||
browserCopyReadmeFile() {
|
||||
return gulp.src("./README_BROWSER.md")
|
||||
.pipe(rename("README.md"))
|
||||
.pipe(gulp.dest("./build/browser-package"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies package_browser.json into package.json for the typeorm-browser package.
|
||||
*/
|
||||
@Task()
|
||||
browserCopyPackageJsonFile() {
|
||||
return gulp.src("./package_browser.json")
|
||||
.pipe(rename("package.json"))
|
||||
.pipe(replace("\"private\": true,", "\"private\": false,"))
|
||||
.pipe(gulp.dest("./build/browser-package"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all tasks for the browser build and package.
|
||||
*/
|
||||
@SequenceTask()
|
||||
browserPackage() {
|
||||
return [
|
||||
["browserCopySources", "browserCopyMainBrowserFile", "browserCopyPlatformTools"],
|
||||
"browserCompile",
|
||||
["browserCopyReadmeFile", "browserUglify", "browserCopyPackageJsonFile"]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes a browser package.
|
||||
*/
|
||||
@Task()
|
||||
browserPublish() {
|
||||
return gulp.src("*.js", { read: false })
|
||||
.pipe(shell([
|
||||
"cd ./build/browser-package && npm publish"
|
||||
]));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Packaging and Publishing tasks
|
||||
// Main Packaging and Publishing tasks
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Publishes a package to npm from ./build/package directory.
|
||||
*/
|
||||
@Task()
|
||||
npmPublish() {
|
||||
nodePublish() {
|
||||
return gulp.src("*.js", { read: false })
|
||||
.pipe(shell([
|
||||
"cd ./build/package && npm publish"
|
||||
@ -186,21 +235,31 @@ export class Gulpfile {
|
||||
* Creates a package that can be published to npm.
|
||||
*/
|
||||
@SequenceTask()
|
||||
package() {
|
||||
nodePackage() {
|
||||
return [
|
||||
"clean",
|
||||
"packageCompile",
|
||||
"packageMoveCompiledFiles",
|
||||
["packageClearCompileDirectory", "packageReplaceReferences", "packagePreparePackageFile"],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a package that can be published to npm.
|
||||
*/
|
||||
@SequenceTask()
|
||||
package() {
|
||||
return [
|
||||
"clean",
|
||||
["nodePackage", "browserPackage"]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a package and publishes it to npm.
|
||||
*/
|
||||
@SequenceTask()
|
||||
publish() {
|
||||
return ["package", "npmPublish"];
|
||||
return ["package", "nodePublish", "browserPublish"];
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
16
package.json
16
package.json
@ -2,7 +2,7 @@
|
||||
"name": "typeorm",
|
||||
"private": true,
|
||||
"version": "0.0.3-alpha.20",
|
||||
"description": "Data-mapper ORM for Typescript",
|
||||
"description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases.",
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README.md",
|
||||
"author": {
|
||||
@ -21,7 +21,19 @@
|
||||
"typescript",
|
||||
"typescript-orm",
|
||||
"mysql",
|
||||
"mysql-orm"
|
||||
"mysql-orm",
|
||||
"postgresql",
|
||||
"postgresql-orm",
|
||||
"mariadb",
|
||||
"mariadb-orm",
|
||||
"sqlite",
|
||||
"sqlite-orm",
|
||||
"sql-server",
|
||||
"sql-server-orm",
|
||||
"oracle",
|
||||
"oracle-orm",
|
||||
"websql",
|
||||
"websql-orm"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/chai": "^3.4.30",
|
||||
|
||||
45
package_browser.json
Normal file
45
package_browser.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "typeorm-browser",
|
||||
"private": true,
|
||||
"version": "0.0.1-alpha.1",
|
||||
"description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases.",
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README.md",
|
||||
"author": {
|
||||
"name": "Umed Khudoiberdiev",
|
||||
"email": "pleerock.me@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/typeorm/typeorm.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/typeorm/typeorm/issues"
|
||||
},
|
||||
"tags": [
|
||||
"orm",
|
||||
"typescript",
|
||||
"typescript-orm",
|
||||
"mysql",
|
||||
"mysql-orm",
|
||||
"postgresql",
|
||||
"postgresql-orm",
|
||||
"mariadb",
|
||||
"mariadb-orm",
|
||||
"sqlite",
|
||||
"sqlite-orm",
|
||||
"sql-server",
|
||||
"sql-server-orm",
|
||||
"oracle",
|
||||
"oracle-orm",
|
||||
"websql",
|
||||
"websql-orm"
|
||||
],
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node_modules/.bin/gulp tests"
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ export class WebsqlQueryRunner implements QueryRunner {
|
||||
if (this.isReleased)
|
||||
throw new QueryRunnerAlreadyReleasedError();
|
||||
|
||||
await this.query(`PRAGMA foreign_keys = OFF;`);
|
||||
// await this.query(`PRAGMA foreign_keys = OFF;`);
|
||||
await this.beginTransaction();
|
||||
try {
|
||||
const selectDropsQuery = `select 'drop table ' || name || ';' as query from sqlite_master where type = 'table' and name != 'sqlite_sequence'`;
|
||||
@ -78,7 +78,7 @@ export class WebsqlQueryRunner implements QueryRunner {
|
||||
|
||||
} finally {
|
||||
await this.release();
|
||||
await this.query(`PRAGMA foreign_keys = ON;`);
|
||||
// await this.query(`PRAGMA foreign_keys = ON;`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ export class WebsqlQueryRunner implements QueryRunner {
|
||||
const tableSchema = new TableSchema(dbTable["name"]);
|
||||
|
||||
// load columns and indices
|
||||
const [dbColumns, dbIndices, dbForeignKeys]: ObjectLiteral[][] = await Promise.all([
|
||||
/*const [dbColumns, dbIndices, dbForeignKeys]: ObjectLiteral[][] = await Promise.all([
|
||||
this.query(`PRAGMA table_info("${dbTable["name"]}")`),
|
||||
this.query(`PRAGMA index_list("${dbTable["name"]}")`),
|
||||
this.query(`PRAGMA foreign_key_list("${dbTable["name"]}")`),
|
||||
@ -368,7 +368,7 @@ export class WebsqlQueryRunner implements QueryRunner {
|
||||
});
|
||||
|
||||
const indices = await Promise.all(indicesPromises);
|
||||
tableSchema.indices = indices.filter(index => !!index) as IndexSchema[];
|
||||
tableSchema.indices = indices.filter(index => !!index) as IndexSchema[];*/
|
||||
|
||||
return tableSchema;
|
||||
}));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user