Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
**/*.js
**/*.svg
**/*.yml
.all-contributorsrc
.prettierignore
*.lock
.gitignore

packages/teleport-repl-component/src/components.d.ts
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"scripts": {
"lint": "tslint -p . -c tslint.json",
"clean": "lerna run clean --parallel",
"build:notypes": "lerna link && node scripts/build.mjs",
"build": "yarn clean && lerna link && node scripts/build.mjs && yarn types",
"dev": "lerna link && yarn types && node scripts/watcher.mjs",
"types": "lerna run types --stream",
"build": "yarn clean && lerna link && lerna run build",
"dev": "lerna link && yarn build && node scripts/watcher.mjs",
"test": "jest",
"test:perf": "jest __tests__/performance",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -45,6 +43,7 @@
"devDependencies": {
"@types/babel-types": "^7.0.7",
"@types/jest": "^25.1.1",
"@types/node": "^15.12.4",
"@types/prettier": "^2.1.6",
"@types/rimraf": "^2.0.3",
"all-contributors-cli": "^6.13.0",
Expand All @@ -53,7 +52,6 @@
"codecov": "^3.8.0",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.0.2",
"esbuild": "^0.12.1",
"husky": "^3.0.4",
"jest": "^26.6.3",
"lerna": "^3.16.4",
Expand All @@ -63,8 +61,7 @@
"ts-jest": "^26.5.6",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.2.4",
"walkdir": "^0.4.1"
"typescript": "^4.2.4"
},
"config": {
"commitizen": {
Expand Down
10 changes: 2 additions & 8 deletions packages/teleport-code-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
"description": "A standalone version of the teleport ecosystem with all the project and component generators installed",
"author": "teleportHQ",
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +20,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator-angular": "^0.17.2",
Expand Down
33 changes: 23 additions & 10 deletions packages/teleport-code-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import {
} from '@teleporthq/teleport-project-generator-gatsby'

import { createZipPublisher } from '@teleporthq/teleport-publisher-zip'
import { createDiskPublisher } from '@teleporthq/teleport-publisher-disk'
import { createVercelPublisher } from '@teleporthq/teleport-publisher-vercel'
import { createNetlifyPublisher } from '@teleporthq/teleport-publisher-netlify'
import { createGithubPublisher } from '@teleporthq/teleport-publisher-github'
Expand All @@ -79,6 +78,7 @@ import { createVueComponentGenerator } from '@teleporthq/teleport-component-gene
import { createStencilComponentGenerator } from '@teleporthq/teleport-component-generator-stencil'
import { createAngularComponentGenerator } from '@teleporthq/teleport-component-generator-angular'
import { createReactNativeComponentGenerator } from '@teleporthq/teleport-component-generator-reactnative'
import { isNodeProcess } from './utils'

const componentGeneratorFactories: Record<ComponentType, ComponentGeneratorInstance> = {
[ComponentType.REACT]: createReactComponentGenerator,
Expand Down Expand Up @@ -124,9 +124,9 @@ const templates = {
[ProjectType.GATSBY]: GatsbyTemplate,
}

const projectPublisherFactories = {
/* tslint:disable ban-types */
const projectPublisherFactories: Omit<Record<PublisherType, Function>, PublisherType.DISK> = {
[PublisherType.ZIP]: createZipPublisher,
[PublisherType.DISK]: createDiskPublisher,
[PublisherType.VERCEL]: createVercelPublisher,
[PublisherType.NETLIFY]: createNetlifyPublisher,
[PublisherType.GITHUB]: createGithubPublisher,
Expand All @@ -135,11 +135,24 @@ const projectPublisherFactories = {

export const packProject: PackProjectFunction = async (
projectUIDL,
{ projectType, publisher, publishOptions = {}, assets = [], plugins = [] }
{ projectType, publisher: publisherType, publishOptions = {}, assets = [], plugins = [] }
) => {
const packer = createProjectPacker()
const projectGeneratorFactory = projectGeneratorFactories[projectType]
let publisher
if (publisherType === PublisherType.DISK) {
if (isNodeProcess()) {
const createDiskPublisher = await import('@teleporthq/teleport-publisher-disk').then(
(mod) => mod.createDiskPublisher
)
publisher = createDiskPublisher
} else {
throw Error(`${PublisherType.DISK} can only be used inside node environments`)
}
} else {
publisher = projectPublisherFactories[publisherType]
}

const projectGeneratorFactory = projectGeneratorFactories[projectType]
if (plugins?.length > 0) {
projectGeneratorFactory.cleanPlugins()
plugins.forEach((plugin: ProjectPlugin) => {
Expand All @@ -148,16 +161,16 @@ export const packProject: PackProjectFunction = async (
}

const projectTemplate =
projectType === ProjectType.PREACT && publisher === PublisherType.CODESANDBOX
projectType === ProjectType.PREACT && publisherType === PublisherType.CODESANDBOX
? PreactCodesandBoxTemplate
: templates[projectType]

if (!projectGeneratorFactory) {
throw new InvalidProjectTypeError(projectType)
}

if (publisher && !projectPublisherFactories[publisher]) {
throw new InvalidPublisherTypeError(publisher)
if (publisherType && !publisher) {
throw new InvalidPublisherTypeError(publisherType)
}

packer.setAssets({
Expand All @@ -169,8 +182,8 @@ export const packProject: PackProjectFunction = async (
packer.setTemplate(projectTemplate)

// If no publisher is provided, the packer will return the generated project
if (publisher) {
const publisherFactory = projectPublisherFactories[publisher]
if (publisherType) {
const publisherFactory = publisher
const projectPublisher = publisherFactory(publishOptions)
// @ts-ignore
packer.setPublisher(projectPublisher)
Expand Down
7 changes: 7 additions & 0 deletions packages/teleport-code-generator/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const isNodeProcess = (): boolean => {
return (
typeof process === 'object' &&
typeof process.versions === 'object' &&
typeof process.versions.node !== 'undefined'
)
}
3 changes: 1 addition & 2 deletions packages/teleport-code-generator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
9 changes: 2 additions & 7 deletions packages/teleport-component-generator-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"homepage": "https://teleporthq.io/",
"license": "MIT",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"publishConfig": {
"access": "public"
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/teleport-component-generator-angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
9 changes: 2 additions & 7 deletions packages/teleport-component-generator-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/teleport-component-generator-preact/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
9 changes: 2 additions & 7 deletions packages/teleport-component-generator-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/teleport-component-generator-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
9 changes: 2 additions & 7 deletions packages/teleport-component-generator-stencil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/teleport-component-generator-stencil/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
9 changes: 2 additions & 7 deletions packages/teleport-component-generator-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
"license": "MIT",
"homepage": "https://teleporthq.io/",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"exports": {
"module": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"types": "dist/cjs/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
Expand All @@ -26,7 +21,7 @@
},
"scripts": {
"clean": "rimraf dist",
"types": "tsc -p tsconfig.json"
"build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
},
"dependencies": {
"@teleporthq/teleport-component-generator": "^0.17.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/teleport-component-generator-vue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"outDir": "dist/cjs"
"outDir": "dist/esm"
},
"include": [
"./src"
Expand Down
Loading