Skip to content

Fix init workspace after account refactoring #8799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _api-extractor-temp/
temp/
.idea
pods/workspace/init/
pods/workspace/init-scripts/

# Logs
*.log
Expand Down
8 changes: 5 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@
"MODEL_VERSION": "v0.7.1",
"WS_OPERATION": "all+backup",
"BACKUP_STORAGE": "minio|minio?accessKey=minioadmin&secretKey=minioadmin",
"BACKUP_BUCKET": "dev-backups"
// "INIT_REPO_DIR": "${workspaceRoot}/pods/workspace/init",
// "INIT_WORKSPACE": "staging-dev"
"BACKUP_BUCKET": "dev-backups",
"INIT_REPO_DIR": "${workspaceRoot}/pods/workspace/init",
"INIT_WORKSPACE": "staging-dev",
"QUEUE_CONFIG": "huly.local:19092",
"QUEUE_REGION": ""
},
"runtimeVersion": "20",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
Expand Down
25 changes: 13 additions & 12 deletions packages/importer/src/huly/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ import * as yaml from 'js-yaml'
import { contentType } from 'mime-types'
import * as path from 'path'
import { IntlString } from '../../../platform/types'
import { Props, UnifiedDoc, UnifiedUpdate, UnifiedFile, UnifiedMixin } from '../types'
import { MetadataRegistry, AssociationMetadata } from './registry'
import { readMarkdownContent, readYamlHeader } from './parsing'
import { Logger } from '../importer/logger'
import { validateSchema } from './validation'
import { Props, UnifiedDoc, UnifiedFile, UnifiedMixin, UnifiedUpdate } from '../types'
import { UnifiedFormatParser } from './parser'
import { AssociationMetadata, MetadataRegistry } from './registry'
import {
AssociationSchema,
BaseFieldType,
Expand All @@ -51,6 +50,7 @@ import {
StringFieldType,
TagSchema
} from './schema'
import { validateSchema } from './validation'

export interface UnifiedDocProcessResult {
docs: Map<string, Array<UnifiedDoc<Doc>>>
Expand All @@ -62,11 +62,12 @@ export interface UnifiedDocProcessResult {
export class CardsProcessor {
constructor (
private readonly metadataRegistry: MetadataRegistry,
private readonly parser: UnifiedFormatParser,
private readonly logger: Logger
) {}

async processDirectory (directoryPath: string): Promise<UnifiedDocProcessResult> {
this.logger.log('Start looking for cards stuff in:', directoryPath)
this.logger.log('Start looking for cards stuff in:' + directoryPath)

const result: UnifiedDocProcessResult = {
docs: new Map(),
Expand Down Expand Up @@ -128,7 +129,7 @@ export class CardsProcessor {

for (const entry of yamlFiles) {
const yamlPath = path.resolve(currentPath, entry.name)
this.logger.log('Reading yaml file:', yamlPath)
this.logger.log('Reading yaml file: ' + yamlPath)
const yamlConfig = yaml.load(fs.readFileSync(yamlPath, 'utf8')) as Record<string, any>

switch (yamlConfig?.class) {
Expand Down Expand Up @@ -199,7 +200,7 @@ export class CardsProcessor {
for (const entry of entries) {
if (entry.isFile() && entry.name.endsWith('.md')) {
const cardPath = path.join(currentPath, entry.name)
const { class: cardType, ...cardProps } = await readYamlHeader(cardPath)
const { class: cardType, ...cardProps } = this.parser.readYamlHeader(cardPath)

if (masterTagId !== undefined) {
await this.processCard(result, cardPath, cardProps, masterTagId, masterTagAssociaions, masterTagAttributes)
Expand Down Expand Up @@ -231,9 +232,9 @@ export class CardsProcessor {
for (const entry of entries) {
if (entry.isFile() && entry.name.endsWith('.md')) {
const cardPath = path.join(currentDir, entry.name)
const { class: cardType, ...cardProps } = await readYamlHeader(cardPath)
const { class: cardType, ...cardProps } = this.parser.readYamlHeader(cardPath)

if (cardType.startsWith('card:types:') === false) {
if (cardType !== undefined && cardType.startsWith('card:types:') === false) {
throw new Error('Unsupported card type: ' + cardType + ' in ' + cardPath)
}

Expand All @@ -253,7 +254,7 @@ export class CardsProcessor {
masterTagAttributes: Map<string, UnifiedDoc<Attribute<MasterTag>>>,
parentCardId?: Ref<Card>
): Promise<void> {
this.logger.log('Processing card:', cardPath)
this.logger.log('Processing card: ' + cardPath)

if (cardProps.blobs !== undefined) {
await this.createBlobs(cardProps.blobs, cardPath, result)
Expand Down Expand Up @@ -310,7 +311,7 @@ export class CardsProcessor {

for (const entry of entries) {
const childCardPath = path.join(cardDir, entry.name)
const { class: cardClass, ...cardProps } = await readYamlHeader(childCardPath)
const { class: cardClass, ...cardProps } = this.parser.readYamlHeader(childCardPath)
await this.processCard(
result,
childCardPath,
Expand Down Expand Up @@ -594,7 +595,7 @@ export class CardsProcessor {
{
_class: masterTagId,
collabField: 'content',
contentProvider: () => readMarkdownContent(cardPath),
contentProvider: () => Promise.resolve(this.parser.readMarkdownContent(cardPath)),
props: cardProps as Props<Card>
},
...relations
Expand Down
Loading
Loading