mirror of
https://github.com/mattermost/focalboard.git
synced 2025-06-02 23:32:31 +00:00
Update import examples
This commit is contained in:
parent
b32ddd5544
commit
e279968793
103
import/asana/.eslintrc.json
Normal file
103
import/asana/.eslintrc.json
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"extends": [
|
||||
],
|
||||
"plugins": [
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": "webpack",
|
||||
"react": {
|
||||
"pragma": "React",
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-expressions": 0,
|
||||
"eol-last": ["error", "always"],
|
||||
"import/no-unresolved": 2,
|
||||
"no-undefined": 0,
|
||||
"react/jsx-filename-extension": 0,
|
||||
"max-nested-callbacks": ["error", {"max": 5}]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.tsx", "**/*.ts"],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"import/no-unresolved": 0, // ts handles this better
|
||||
"camelcase": 0,
|
||||
"semi": "off",
|
||||
"@typescript-eslint/naming-convention": [
|
||||
2,
|
||||
{
|
||||
"selector": "function",
|
||||
"format": ["camelCase", "PascalCase"]
|
||||
},
|
||||
{
|
||||
"selector": "variable",
|
||||
"format": ["camelCase", "PascalCase", "UPPER_CASE"]
|
||||
},
|
||||
{
|
||||
"selector": "parameter",
|
||||
"format": ["camelCase", "PascalCase"],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"vars": "all",
|
||||
"args": "after-used"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/prefer-interface": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"@typescript-eslint/semi": [2, "never"],
|
||||
"@typescript-eslint/indent": [
|
||||
2,
|
||||
4,
|
||||
{
|
||||
"SwitchCase": 0
|
||||
}
|
||||
],
|
||||
"no-use-before-define": "off",
|
||||
"@typescript-eslint/no-use-before-define": [
|
||||
2,
|
||||
{
|
||||
"classes": false,
|
||||
"functions": false,
|
||||
"variables": false
|
||||
}
|
||||
],
|
||||
"no-useless-constructor": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 2,
|
||||
"react/jsx-filename-extension": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["tests/**", "**/*.test.*"],
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"rules": {
|
||||
"func-names": 0,
|
||||
"global-require": 0,
|
||||
"new-cap": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-import-assign": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
2
import/asana/.gitignore
vendored
Normal file
2
import/asana/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
test
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
// Generated by https://quicktype.io
|
||||
//
|
||||
// To change quicktype's target language, run command:
|
||||
|
@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
import * as fs from 'fs'
|
||||
import minimist from 'minimist'
|
||||
import {exit} from 'process'
|
||||
import {Z_FIXED} from 'zlib'
|
||||
import {IArchive} from '../../webapp/src/blocks/archive'
|
||||
import {IBlock} from '../../webapp/src/blocks/block'
|
||||
import {IPropertyOption, IPropertyTemplate, MutableBoard} from '../../webapp/src/blocks/board'
|
||||
@ -23,6 +26,11 @@ function main() {
|
||||
showHelp()
|
||||
}
|
||||
|
||||
if (!fs.existsSync(inputFile)) {
|
||||
console.error(`File not found: ${inputFile}`)
|
||||
exit(2)
|
||||
}
|
||||
|
||||
// Read input
|
||||
const inputData = fs.readFileSync(inputFile, 'utf-8')
|
||||
const input = JSON.parse(inputData) as Asana
|
||||
@ -38,32 +46,32 @@ function main() {
|
||||
}
|
||||
|
||||
function getProjects(input: Asana): Workspace[] {
|
||||
const projectMap = new Map<string, Workspace>()
|
||||
const projectMap = new Map<string, Workspace>()
|
||||
|
||||
input.data.forEach(datum => {
|
||||
datum.projects.forEach(project => {
|
||||
if (!projectMap.get(project.gid)) {
|
||||
projectMap.set(project.gid, project)
|
||||
}
|
||||
})
|
||||
})
|
||||
input.data.forEach(datum => {
|
||||
datum.projects.forEach(project => {
|
||||
if (!projectMap.get(project.gid)) {
|
||||
projectMap.set(project.gid, project)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return [...projectMap.values()]
|
||||
return [...projectMap.values()]
|
||||
}
|
||||
|
||||
function getSections(input: Asana, projectId: string): Workspace[] {
|
||||
const sectionMap = new Map<string, Workspace>()
|
||||
const sectionMap = new Map<string, Workspace>()
|
||||
|
||||
input.data.forEach(datum => {
|
||||
const membership = datum.memberships.find(o => o.project.gid === projectId)
|
||||
if (membership) {
|
||||
if (!sectionMap.get(membership.section.gid)) {
|
||||
sectionMap.set(membership.section.gid, membership.section)
|
||||
}
|
||||
}
|
||||
})
|
||||
input.data.forEach(datum => {
|
||||
const membership = datum.memberships.find(o => o.project.gid === projectId)
|
||||
if (membership) {
|
||||
if (!sectionMap.get(membership.section.gid)) {
|
||||
sectionMap.set(membership.section.gid, membership.section)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return [...sectionMap.values()]
|
||||
return [...sectionMap.values()]
|
||||
}
|
||||
|
||||
function convert(input: Asana): IArchive {
|
||||
@ -73,14 +81,14 @@ function convert(input: Asana): IArchive {
|
||||
blocks: []
|
||||
}
|
||||
|
||||
const projects = getProjects(input)
|
||||
if (projects.length < 1) {
|
||||
console.error('No projects found')
|
||||
return archive
|
||||
}
|
||||
const projects = getProjects(input)
|
||||
if (projects.length < 1) {
|
||||
console.error('No projects found')
|
||||
return archive
|
||||
}
|
||||
|
||||
// TODO: Handle multiple projects
|
||||
const project = projects[0]
|
||||
// TODO: Handle multiple projects
|
||||
const project = projects[0]
|
||||
|
||||
const blocks: IBlock[] = []
|
||||
|
||||
@ -93,7 +101,7 @@ function convert(input: Asana): IArchive {
|
||||
// Convert sections (columns) to a Select property
|
||||
const optionIdMap = new Map<string, string>()
|
||||
const options: IPropertyOption[] = []
|
||||
const sections = getSections(input, project.gid)
|
||||
const sections = getSections(input, project.gid)
|
||||
sections.forEach(section => {
|
||||
const optionId = Utils.createGuid()
|
||||
optionIdMap.set(section.gid, optionId)
|
||||
@ -132,7 +140,7 @@ function convert(input: Asana): IArchive {
|
||||
outCard.parentId = board.id
|
||||
|
||||
// Map lists to Select property options
|
||||
const membership = card.memberships.find(o => o.project.gid === project.gid)
|
||||
const membership = card.memberships.find(o => o.project.gid === project.gid)
|
||||
if (membership) {
|
||||
const optionId = optionIdMap.get(membership.section.gid)
|
||||
if (optionId) {
|
||||
@ -158,7 +166,7 @@ function convert(input: Asana): IArchive {
|
||||
}
|
||||
})
|
||||
|
||||
archive.blocks = blocks
|
||||
archive.blocks = blocks
|
||||
|
||||
console.log('')
|
||||
console.log(`Found ${input.data.length} card(s).`)
|
||||
@ -168,7 +176,7 @@ function convert(input: Asana): IArchive {
|
||||
|
||||
function showHelp() {
|
||||
console.log('import -i <input.json> -o [output.focalboard]')
|
||||
exit(-1)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
main()
|
||||
|
@ -5,7 +5,10 @@
|
||||
"description": "",
|
||||
"main": "importAsana.js",
|
||||
"scripts": {
|
||||
"test": "ts-node importAsana.ts -i test/asana.json -o test/archive.focalboard"
|
||||
"lint": "eslint --ext .tsx,.ts . --quiet --cache",
|
||||
"fix": "eslint --ext .tsx,.ts . --quiet --fix --cache",
|
||||
"test": "ts-node importAsana.ts -i test/asana.json -o test/archive.focalboard",
|
||||
"debug:test": "node --inspect=5858 -r ts-node/register importAsana.ts -i test/asana.json -o test/archive.focalboard"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
class Utils {
|
||||
|
103
import/trello/.eslintrc.json
Normal file
103
import/trello/.eslintrc.json
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"extends": [
|
||||
],
|
||||
"plugins": [
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": "webpack",
|
||||
"react": {
|
||||
"pragma": "React",
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-expressions": 0,
|
||||
"eol-last": ["error", "always"],
|
||||
"import/no-unresolved": 2,
|
||||
"no-undefined": 0,
|
||||
"react/jsx-filename-extension": 0,
|
||||
"max-nested-callbacks": ["error", {"max": 5}]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.tsx", "**/*.ts"],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"import/no-unresolved": 0, // ts handles this better
|
||||
"camelcase": 0,
|
||||
"semi": "off",
|
||||
"@typescript-eslint/naming-convention": [
|
||||
2,
|
||||
{
|
||||
"selector": "function",
|
||||
"format": ["camelCase", "PascalCase"]
|
||||
},
|
||||
{
|
||||
"selector": "variable",
|
||||
"format": ["camelCase", "PascalCase", "UPPER_CASE"]
|
||||
},
|
||||
{
|
||||
"selector": "parameter",
|
||||
"format": ["camelCase", "PascalCase"],
|
||||
"leadingUnderscore": "allow"
|
||||
},
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"vars": "all",
|
||||
"args": "after-used"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/prefer-interface": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"@typescript-eslint/semi": [2, "never"],
|
||||
"@typescript-eslint/indent": [
|
||||
2,
|
||||
4,
|
||||
{
|
||||
"SwitchCase": 0
|
||||
}
|
||||
],
|
||||
"no-use-before-define": "off",
|
||||
"@typescript-eslint/no-use-before-define": [
|
||||
2,
|
||||
{
|
||||
"classes": false,
|
||||
"functions": false,
|
||||
"variables": false
|
||||
}
|
||||
],
|
||||
"no-useless-constructor": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 2,
|
||||
"react/jsx-filename-extension": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["tests/**", "**/*.test.*"],
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"rules": {
|
||||
"func-names": 0,
|
||||
"global-require": 0,
|
||||
"new-cap": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-import-assign": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
1
import/trello/.gitignore
vendored
Normal file
1
import/trello/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
test
|
@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
import * as fs from 'fs'
|
||||
import minimist from 'minimist'
|
||||
import {exit} from 'process'
|
||||
@ -23,6 +25,11 @@ function main() {
|
||||
showHelp()
|
||||
}
|
||||
|
||||
if (!fs.existsSync(inputFile)) {
|
||||
console.error(`File not found: ${inputFile}`)
|
||||
exit(2)
|
||||
}
|
||||
|
||||
// Read input
|
||||
const inputData = fs.readFileSync(inputFile, 'utf-8')
|
||||
const input = JSON.parse(inputData) as Trello
|
||||
@ -127,7 +134,7 @@ function convert(input: Trello): IArchive {
|
||||
|
||||
function showHelp() {
|
||||
console.log('import -i <input.json> -o [output.focalboard]')
|
||||
exit(-1)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
main()
|
||||
|
@ -5,7 +5,10 @@
|
||||
"description": "",
|
||||
"main": "importTrello.js",
|
||||
"scripts": {
|
||||
"test": "ts-node importTrello.ts -i test/trello.json -o test/archive.focalboard"
|
||||
"lint": "eslint --ext .tsx,.ts . --quiet --cache",
|
||||
"fix": "eslint --ext .tsx,.ts . --quiet --fix --cache",
|
||||
"test": "ts-node importTrello.ts -i test/trello.json -o test/archive.focalboard",
|
||||
"debug:test": "node --inspect=5858 -r ts-node/register importTrello.ts -i test/trello.json -o test/archive.focalboard"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
// Generated by https://quicktype.io
|
||||
//
|
||||
// To change quicktype's target language, run command:
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
class Utils {
|
||||
|
Loading…
Reference in New Issue
Block a user