Skip to content
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

Update relations generate #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 16 additions & 16 deletions bin/lb-ios
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var semver = require('semver');
var mkdirp = require('mkdirp');
var optimist = require('optimist');
let fs = require('fs');
let path = require('path');
let semver = require('semver');
let mkdirp = require('mkdirp');
let optimist = require('optimist');

// var generator = require(loopback-sdk-ios-codegen);
var generator = require('../lib/objc-codegen');
// let generator = require(loopback-sdk-ios-codegen);
let generator = require('../lib/objc-codegen');

var argv = optimist
let argv = optimist
.usage('Generate iOS Objective-C client code for your LoopBack application.' +
'\nUsage:' +
'\n $0 [options] path-to-app ios-client-dir-path' +
Expand All @@ -25,27 +25,27 @@ var argv = optimist
.argv;

try {
var appFile = path.resolve(argv._[0]);
var clientDir = path.resolve(argv._[1]);
var modelPrefix = argv['model-name-prefix'];
var verbose = argv['verbose'];
let appFile = path.resolve(argv._[0]);
let clientDir = path.resolve(argv._[1]);
let modelPrefix = argv['model-name-prefix'];
let verbose = argv['verbose'];

console.error('Loading LoopBack app %j', appFile);
var app = require(appFile);
let app = require(appFile);
assertLoopBackVersion(app);
if (verbose) {
console.error('Loopback version: ' + app.loopback.version);
}

console.error('Generating iOS models with prefix %j', modelPrefix);
var files = generator.objcModels(app, modelPrefix, verbose);
let files = generator.objcModels(app, modelPrefix, verbose);

if (!fs.existsSync(clientDir)){
mkdirp.mkdirP.sync(clientDir);
}

for (var objcFileName in files) {
var filepath = path.resolve(clientDir, objcFileName);
for (let objcFileName in files) {
let filepath = path.resolve(clientDir, objcFileName);
console.log('Writing: ' + filepath);
if (verbose) {
console.error('--');
Expand Down
13 changes: 13 additions & 0 deletions lib/objc-all-h.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// LoopbackModelImport.h
//

<% for (var model in meta) {
if (meta.hasOwnProperty(model)) {
-%>
#import "<%- meta[model].objcModelName %>.h"
#import "<%- meta[model].objcModelName %>Repository.h"
<%
}
}
-%>
Loading